@wordpress/edit-site 3.0.24 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +7 -1
  4. package/build/components/block-editor/resizable-editor.js +1 -0
  5. package/build/components/block-editor/resizable-editor.js.map +1 -1
  6. package/build/components/code-editor/code-editor-text-area.js +95 -0
  7. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  8. package/build/components/code-editor/index.js +79 -0
  9. package/build/components/code-editor/index.js.map +1 -0
  10. package/build/components/editor/index.js +39 -9
  11. package/build/components/editor/index.js.map +1 -1
  12. package/build/components/global-styles/border-panel.js +81 -22
  13. package/build/components/global-styles/border-panel.js.map +1 -1
  14. package/build/components/global-styles/context-menu.js +4 -6
  15. package/build/components/global-styles/context-menu.js.map +1 -1
  16. package/build/components/global-styles/global-styles-provider.js +1 -0
  17. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  18. package/build/components/global-styles/header.js +2 -7
  19. package/build/components/global-styles/header.js.map +1 -1
  20. package/build/components/global-styles/navigation-button.js +35 -12
  21. package/build/components/global-styles/navigation-button.js.map +1 -1
  22. package/build/components/global-styles/palette.js +3 -3
  23. package/build/components/global-styles/palette.js.map +1 -1
  24. package/build/components/global-styles/preview.js +46 -15
  25. package/build/components/global-styles/preview.js.map +1 -1
  26. package/build/components/global-styles/screen-background-color.js +9 -12
  27. package/build/components/global-styles/screen-background-color.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +2 -3
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-block.js +0 -1
  31. package/build/components/global-styles/screen-block.js.map +1 -1
  32. package/build/components/global-styles/screen-color-palette.js +0 -2
  33. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  34. package/build/components/global-styles/screen-colors.js +5 -6
  35. package/build/components/global-styles/screen-colors.js.map +1 -1
  36. package/build/components/global-styles/screen-layout.js +0 -2
  37. package/build/components/global-styles/screen-layout.js.map +1 -1
  38. package/build/components/global-styles/screen-link-color.js +6 -12
  39. package/build/components/global-styles/screen-link-color.js.map +1 -1
  40. package/build/components/global-styles/screen-root.js +22 -3
  41. package/build/components/global-styles/screen-root.js.map +1 -1
  42. package/build/components/global-styles/screen-style-variations.js +138 -0
  43. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  44. package/build/components/global-styles/screen-text-color.js +6 -12
  45. package/build/components/global-styles/screen-text-color.js.map +1 -1
  46. package/build/components/global-styles/screen-typography-element.js +0 -2
  47. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  48. package/build/components/global-styles/screen-typography.js +2 -3
  49. package/build/components/global-styles/screen-typography.js.map +1 -1
  50. package/build/components/global-styles/ui.js +31 -14
  51. package/build/components/global-styles/ui.js.map +1 -1
  52. package/build/components/header/index.js +12 -4
  53. package/build/components/header/index.js.map +1 -1
  54. package/build/components/header/mode-switcher/index.js +78 -0
  55. package/build/components/header/mode-switcher/index.js.map +1 -0
  56. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  57. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  58. package/build/components/header/more-menu/index.js +72 -39
  59. package/build/components/header/more-menu/index.js.map +1 -1
  60. package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
  61. package/build/components/header/more-menu/site-export.js.map +1 -0
  62. package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  63. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  64. package/build/components/header/tools-more-menu-group/index.js +1 -5
  65. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  66. package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
  67. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  68. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
  69. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  70. package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
  71. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  72. package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
  73. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  74. package/build/components/keyboard-shortcuts/index.js +26 -1
  75. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  76. package/build/components/list/actions/index.js +5 -4
  77. package/build/components/list/actions/index.js.map +1 -1
  78. package/build/components/list/actions/rename-menu-item.js +3 -3
  79. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  80. package/build/components/list/added-by.js +51 -50
  81. package/build/components/list/added-by.js.map +1 -1
  82. package/build/components/routes/redirect-to-homepage.js +87 -0
  83. package/build/components/routes/redirect-to-homepage.js.map +1 -0
  84. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  85. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  86. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  87. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  88. package/build/components/sidebar/default-sidebar.js +4 -2
  89. package/build/components/sidebar/default-sidebar.js.map +1 -1
  90. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  91. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  92. package/build/components/url-query-controller/index.js +1 -38
  93. package/build/components/url-query-controller/index.js.map +1 -1
  94. package/build/index.js +10 -5
  95. package/build/index.js.map +1 -1
  96. package/build/store/actions.js +29 -27
  97. package/build/store/actions.js.map +1 -1
  98. package/build/store/defaults.js +2 -1
  99. package/build/store/defaults.js.map +1 -1
  100. package/build/store/reducer.js +11 -0
  101. package/build/store/reducer.js.map +1 -1
  102. package/build/store/selectors.js +13 -0
  103. package/build/store/selectors.js.map +1 -1
  104. package/build-module/components/block-editor/resizable-editor.js +1 -0
  105. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  106. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  107. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  108. package/build-module/components/code-editor/index.js +62 -0
  109. package/build-module/components/code-editor/index.js.map +1 -0
  110. package/build-module/components/editor/index.js +38 -10
  111. package/build-module/components/editor/index.js.map +1 -1
  112. package/build-module/components/global-styles/border-panel.js +82 -23
  113. package/build-module/components/global-styles/border-panel.js.map +1 -1
  114. package/build-module/components/global-styles/context-menu.js +1 -1
  115. package/build-module/components/global-styles/context-menu.js.map +1 -1
  116. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  117. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  118. package/build-module/components/global-styles/header.js +2 -5
  119. package/build-module/components/global-styles/header.js.map +1 -1
  120. package/build-module/components/global-styles/navigation-button.js +35 -10
  121. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  122. package/build-module/components/global-styles/palette.js +2 -2
  123. package/build-module/components/global-styles/palette.js.map +1 -1
  124. package/build-module/components/global-styles/preview.js +45 -15
  125. package/build-module/components/global-styles/preview.js.map +1 -1
  126. package/build-module/components/global-styles/screen-background-color.js +9 -13
  127. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  128. package/build-module/components/global-styles/screen-block-list.js +1 -2
  129. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  130. package/build-module/components/global-styles/screen-block.js +0 -1
  131. package/build-module/components/global-styles/screen-block.js.map +1 -1
  132. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  133. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  134. package/build-module/components/global-styles/screen-colors.js +2 -3
  135. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  136. package/build-module/components/global-styles/screen-layout.js +0 -2
  137. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  138. package/build-module/components/global-styles/screen-link-color.js +7 -13
  139. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  140. package/build-module/components/global-styles/screen-root.js +21 -4
  141. package/build-module/components/global-styles/screen-root.js.map +1 -1
  142. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  143. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  144. package/build-module/components/global-styles/screen-text-color.js +7 -13
  145. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  146. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  147. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  148. package/build-module/components/global-styles/screen-typography.js +1 -2
  149. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  150. package/build-module/components/global-styles/ui.js +29 -14
  151. package/build-module/components/global-styles/ui.js.map +1 -1
  152. package/build-module/components/header/index.js +13 -5
  153. package/build-module/components/header/index.js.map +1 -1
  154. package/build-module/components/header/mode-switcher/index.js +65 -0
  155. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  156. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  157. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  158. package/build-module/components/header/more-menu/index.js +67 -40
  159. package/build-module/components/header/more-menu/index.js.map +1 -1
  160. package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
  161. package/build-module/components/header/more-menu/site-export.js.map +1 -0
  162. package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  163. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  164. package/build-module/components/header/tools-more-menu-group/index.js +2 -5
  165. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  166. package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
  167. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  168. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
  169. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  170. package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  172. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
  173. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  174. package/build-module/components/keyboard-shortcuts/index.js +26 -1
  175. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  176. package/build-module/components/list/actions/index.js +5 -4
  177. package/build-module/components/list/actions/index.js.map +1 -1
  178. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  179. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  180. package/build-module/components/list/added-by.js +52 -51
  181. package/build-module/components/list/added-by.js.map +1 -1
  182. package/build-module/components/routes/redirect-to-homepage.js +75 -0
  183. package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
  184. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  185. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  186. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  187. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  188. package/build-module/components/sidebar/default-sidebar.js +4 -2
  189. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  190. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  191. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  192. package/build-module/components/url-query-controller/index.js +3 -40
  193. package/build-module/components/url-query-controller/index.js.map +1 -1
  194. package/build-module/index.js +9 -4
  195. package/build-module/index.js.map +1 -1
  196. package/build-module/store/actions.js +25 -25
  197. package/build-module/store/actions.js.map +1 -1
  198. package/build-module/store/defaults.js +2 -1
  199. package/build-module/store/defaults.js.map +1 -1
  200. package/build-module/store/reducer.js +11 -0
  201. package/build-module/store/reducer.js.map +1 -1
  202. package/build-module/store/selectors.js +11 -0
  203. package/build-module/store/selectors.js.map +1 -1
  204. package/build-style/style-rtl.css +202 -72
  205. package/build-style/style.css +202 -72
  206. package/package.json +28 -30
  207. package/src/components/block-editor/resizable-editor.js +1 -0
  208. package/src/components/block-editor/style.scss +15 -23
  209. package/src/components/code-editor/code-editor-text-area.js +79 -0
  210. package/src/components/code-editor/index.js +65 -0
  211. package/src/components/code-editor/style.scss +100 -0
  212. package/src/components/editor/index.js +55 -10
  213. package/src/components/global-styles/border-panel.js +106 -42
  214. package/src/components/global-styles/context-menu.js +1 -1
  215. package/src/components/global-styles/global-styles-provider.js +1 -2
  216. package/src/components/global-styles/header.js +3 -5
  217. package/src/components/global-styles/navigation-button.js +31 -10
  218. package/src/components/global-styles/palette.js +6 -2
  219. package/src/components/global-styles/preview.js +46 -18
  220. package/src/components/global-styles/screen-background-color.js +7 -12
  221. package/src/components/global-styles/screen-block-list.js +1 -2
  222. package/src/components/global-styles/screen-block.js +1 -1
  223. package/src/components/global-styles/screen-color-palette.js +0 -2
  224. package/src/components/global-styles/screen-colors.js +2 -3
  225. package/src/components/global-styles/screen-layout.js +1 -5
  226. package/src/components/global-styles/screen-link-color.js +6 -16
  227. package/src/components/global-styles/screen-root.js +32 -3
  228. package/src/components/global-styles/screen-style-variations.js +130 -0
  229. package/src/components/global-styles/screen-text-color.js +6 -16
  230. package/src/components/global-styles/screen-typography-element.js +0 -4
  231. package/src/components/global-styles/screen-typography.js +2 -3
  232. package/src/components/global-styles/style.scss +24 -25
  233. package/src/components/global-styles/ui.js +55 -25
  234. package/src/components/header/document-actions/style.scss +1 -9
  235. package/src/components/header/index.js +10 -2
  236. package/src/components/header/mode-switcher/index.js +67 -0
  237. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  238. package/src/components/header/more-menu/index.js +107 -44
  239. package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
  240. package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  241. package/src/components/header/style.scss +2 -1
  242. package/src/components/header/tools-more-menu-group/index.js +2 -7
  243. package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
  244. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
  245. package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
  246. package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
  247. package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
  248. package/src/components/keyboard-shortcuts/index.js +27 -1
  249. package/src/components/list/actions/index.js +5 -4
  250. package/src/components/list/actions/rename-menu-item.js +3 -3
  251. package/src/components/list/added-by.js +57 -63
  252. package/src/components/routes/redirect-to-homepage.js +71 -0
  253. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  254. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  255. package/src/components/secondary-sidebar/style.scss +0 -4
  256. package/src/components/sidebar/default-sidebar.js +2 -0
  257. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  258. package/src/components/sidebar/style.scss +21 -14
  259. package/src/components/url-query-controller/index.js +3 -35
  260. package/src/index.js +10 -3
  261. package/src/store/actions.js +24 -37
  262. package/src/store/defaults.js +1 -0
  263. package/src/store/reducer.js +6 -0
  264. package/src/store/selectors.js +11 -0
  265. package/src/store/test/actions.js +2 -92
  266. package/src/style.scss +2 -0
  267. package/build/plugins/index.js +0 -28
  268. package/build/plugins/index.js.map +0 -1
  269. package/build/plugins/site-export.js.map +0 -1
  270. package/build/plugins/welcome-guide-menu-item.js.map +0 -1
  271. package/build-module/plugins/index.js +0 -20
  272. package/build-module/plugins/index.js.map +0 -1
  273. package/build-module/plugins/site-export.js.map +0 -1
  274. package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
  275. package/src/plugins/index.js +0 -24
@@ -5,10 +5,12 @@ import { createElement } from "@wordpress/element";
5
5
  * WordPress dependencies
6
6
  */
7
7
  import { useSelect, useDispatch } from '@wordpress/data';
8
- import { Button } from '@wordpress/components';
8
+ import { Button, VisuallyHidden } from '@wordpress/components';
9
9
  import { __experimentalLibrary as Library } from '@wordpress/block-editor';
10
10
  import { close } from '@wordpress/icons';
11
11
  import { useViewportMatch, __experimentalUseDialog as useDialog } from '@wordpress/compose';
12
+ import { __ } from '@wordpress/i18n';
13
+ import { useEffect, useRef } from '@wordpress/element';
12
14
  /**
13
15
  * Internal dependencies
14
16
  */
@@ -20,17 +22,24 @@ export default function InserterSidebar() {
20
22
  } = useDispatch(editSiteStore);
21
23
  const insertionPoint = useSelect(select => select(editSiteStore).__experimentalGetInsertionPoint(), []);
22
24
  const isMobile = useViewportMatch('medium', '<');
25
+ const TagName = !isMobile ? VisuallyHidden : 'div';
23
26
  const [inserterDialogRef, inserterDialogProps] = useDialog({
24
- onClose: () => setIsInserterOpened(false)
27
+ onClose: () => setIsInserterOpened(false),
28
+ focusOnMount: null
25
29
  });
30
+ const libraryRef = useRef();
31
+ useEffect(() => {
32
+ libraryRef.current.focusSearch();
33
+ }, []);
26
34
  return createElement("div", _extends({
27
35
  ref: inserterDialogRef
28
36
  }, inserterDialogProps, {
29
37
  className: "edit-site-editor__inserter-panel"
30
- }), createElement("div", {
38
+ }), createElement(TagName, {
31
39
  className: "edit-site-editor__inserter-panel-header"
32
40
  }, createElement(Button, {
33
41
  icon: close,
42
+ label: __('Close block inserter'),
34
43
  onClick: () => setIsInserterOpened(false)
35
44
  })), createElement("div", {
36
45
  className: "edit-site-editor__inserter-panel-content"
@@ -39,7 +48,8 @@ export default function InserterSidebar() {
39
48
  shouldFocusBlock: isMobile,
40
49
  rootClientId: insertionPoint.rootClientId,
41
50
  __experimentalInsertionIndex: insertionPoint.insertionIndex,
42
- __experimentalFilterValue: insertionPoint.filterValue
51
+ __experimentalFilterValue: insertionPoint.filterValue,
52
+ ref: libraryRef
43
53
  })));
44
54
  }
45
55
  //# sourceMappingURL=inserter-sidebar.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/secondary-sidebar/inserter-sidebar.js"],"names":["useSelect","useDispatch","Button","__experimentalLibrary","Library","close","useViewportMatch","__experimentalUseDialog","useDialog","store","editSiteStore","InserterSidebar","setIsInserterOpened","insertionPoint","select","__experimentalGetInsertionPoint","isMobile","inserterDialogRef","inserterDialogProps","onClose","rootClientId","insertionIndex","filterValue"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SA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ies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button } from '@wordpress/components';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { close } from '@wordpress/icons';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst insertionPoint = useSelect(\n\t\t( select ) => select( editSiteStore ).__experimentalGetInsertionPoint(),\n\t\t[]\n\t);\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: () => setIsInserterOpened( false ),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-site-editor__inserter-panel\"\n\t\t>\n\t\t\t<div className=\"edit-site-editor__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tonClick={ () => setIsInserterOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div className=\"edit-site-editor__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobile }\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/secondary-sidebar/inserter-sidebar.js"],"names":["useSelect","useDispatch","Button","VisuallyHidden","__experimentalLibrary","Library","close","useViewportMatch","__experimentalUseDialog","useDialog","__","useEffect","useRef","store","editSiteStore","InserterSidebar","setIsInserterOpened","insertionPoint","select","__experimentalGetInsertionPoint","isMobile","TagName","inserterDialogRef","inserterDialogProps","onClose","focusOnMount","libraryRef","current","focusSearch","rootClientId","insertionIndex","filterValue"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,cAAjB,QAAuC,uBAAvC;AACA,SAASC,qBAAqB,IAAIC,OAAlC,QAAiD,yBAAjD;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SACCC,gBADD,EAECC,uBAAuB,IAAIC,SAF5B,QAGO,oBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,eAAT,GAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAA0Bf,WAAW,CAAEa,aAAF,CAA3C;AACA,QAAMG,cAAc,GAAGjB,SAAS,CAC7BkB,MAAF,IAAcA,MAAM,CAAEJ,aAAF,CAAN,CAAwBK,+BAAxB,EADiB,EAE/B,EAF+B,CAAhC;AAKA,QAAMC,QAAQ,GAAGb,gBAAgB,CAAE,QAAF,EAAY,GAAZ,CAAjC;AACA,QAAMc,OAAO,GAAG,CAAED,QAAF,GAAajB,cAAb,GAA8B,KAA9C;AACA,QAAM,CAAEmB,iBAAF,EAAqBC,mBAArB,IAA6Cd,SAAS,CAAE;AAC7De,IAAAA,OAAO,EAAE,MAAMR,mBAAmB,CAAE,KAAF,CAD2B;AAE7DS,IAAAA,YAAY,EAAE;AAF+C,GAAF,CAA5D;AAKA,QAAMC,UAAU,GAAGd,MAAM,EAAzB;AACAD,EAAAA,SAAS,CAAE,MAAM;AAChBe,IAAAA,UAAU,CAACC,OAAX,CAAmBC,WAAnB;AACA,GAFQ,EAEN,EAFM,CAAT;AAIA,SACC;AACC,IAAA,GAAG,EAAGN;AADP,KAEMC,mBAFN;AAGC,IAAA,SAAS,EAAC;AAHX,MAKC,cAAC,OAAD;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC,cAAC,MAAD;AACC,IAAA,IAAI,EAAGjB,KADR;AAEC,IAAA,KAAK,EAAGI,EAAE,CAAE,sBAAF,CAFX;AAGC,IAAA,OAAO,EAAG,MAAMM,mBAAmB,CAAE,KAAF;AAHpC,IADD,CALD,EAYC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,OAAD;AACC,IAAA,qBAAqB,MADtB;AAEC,IAAA,gBAAgB,EAAGI,QAFpB;AAGC,IAAA,YAAY,EAAGH,cAAc,CAACY,YAH/B;AAIC,IAAA,4BAA4B,EAC3BZ,cAAc,CAACa,cALjB;AAOC,IAAA,yBAAyB,EAAGb,cAAc,CAACc,WAP5C;AAQC,IAAA,GAAG,EAAGL;AARP,IADD,CAZD,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Button, VisuallyHidden } from '@wordpress/components';\nimport { __experimentalLibrary as Library } from '@wordpress/block-editor';\nimport { close } from '@wordpress/icons';\nimport {\n\tuseViewportMatch,\n\t__experimentalUseDialog as useDialog,\n} from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function InserterSidebar() {\n\tconst { setIsInserterOpened } = useDispatch( editSiteStore );\n\tconst insertionPoint = useSelect(\n\t\t( select ) => select( editSiteStore ).__experimentalGetInsertionPoint(),\n\t\t[]\n\t);\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst TagName = ! isMobile ? VisuallyHidden : 'div';\n\tconst [ inserterDialogRef, inserterDialogProps ] = useDialog( {\n\t\tonClose: () => setIsInserterOpened( false ),\n\t\tfocusOnMount: null,\n\t} );\n\n\tconst libraryRef = useRef();\n\tuseEffect( () => {\n\t\tlibraryRef.current.focusSearch();\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ inserterDialogRef }\n\t\t\t{ ...inserterDialogProps }\n\t\t\tclassName=\"edit-site-editor__inserter-panel\"\n\t\t>\n\t\t\t<TagName className=\"edit-site-editor__inserter-panel-header\">\n\t\t\t\t<Button\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close block inserter' ) }\n\t\t\t\t\tonClick={ () => setIsInserterOpened( false ) }\n\t\t\t\t/>\n\t\t\t</TagName>\n\t\t\t<div className=\"edit-site-editor__inserter-panel-content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobile }\n\t\t\t\t\trootClientId={ insertionPoint.rootClientId }\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -30,7 +30,8 @@ export default function ListViewSidebar() {
30
30
  }
31
31
 
32
32
  const focusOnMountRef = useFocusOnMount('firstElement');
33
- const focusReturnRef = useFocusReturn();
33
+ const headerFocusReturnRef = useFocusReturn();
34
+ const contentFocusReturnRef = useFocusReturn();
34
35
 
35
36
  function closeOnEscape(event) {
36
37
  if (event.keyCode === ESCAPE && !event.defaultPrevented) {
@@ -46,16 +47,17 @@ export default function ListViewSidebar() {
46
47
  className: "edit-site-editor__list-view-panel",
47
48
  onKeyDown: closeOnEscape
48
49
  }, createElement("div", {
49
- className: "edit-site-editor__list-view-panel-header"
50
+ className: "edit-site-editor__list-view-panel-header",
51
+ ref: headerFocusReturnRef
50
52
  }, createElement("strong", {
51
53
  id: labelId
52
- }, __('List view')), createElement(Button, {
54
+ }, __('List View')), createElement(Button, {
53
55
  icon: closeSmall,
54
- label: __('Close list view sidebar'),
56
+ label: __('Close List View Sidebar'),
55
57
  onClick: () => setIsListViewOpened(false)
56
58
  })), createElement("div", {
57
59
  className: "edit-site-editor__list-view-panel-content",
58
- ref: useMergeRefs([focusReturnRef, focusOnMountRef])
60
+ ref: useMergeRefs([contentFocusReturnRef, focusOnMountRef])
59
61
  }, createElement(ListView, {
60
62
  onSelect: selectEditorBlock,
61
63
  showNestedBlocks: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"names":["__experimentalListView","ListView","store","blockEditorStore","Button","useFocusOnMount","useFocusReturn","useInstanceId","useMergeRefs","useDispatch","__","closeSmall","ESCAPE","editSiteStore","ListViewSidebar","setIsListViewOpened","clearSelectedBlock","selectBlock","selectEditorBlock","clientId","focusOnMountRef","focusReturnRef","closeOnEscape","event","keyCode","defaultPrevented","instanceId","labelId"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,sBAAsB,IAAIC,QAD3B,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SACCC,eADD,EAECC,cAFD,EAGCC,aAHD,EAICC,YAJD,QAKO,oBALP;AAMA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,eAAT,GAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAA0BN,WAAW,CAAEI,aAAF,CAA3C;AAEA,QAAM;AAAEG,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAAsCR,WAAW,CAAEN,gBAAF,CAAvD;;AACA,iBAAee,iBAAf,CAAkCC,QAAlC,EAA6C;AAC5C,UAAMH,kBAAkB,EAAxB;AACAC,IAAAA,WAAW,CAAEE,QAAF,EAAY,CAAC,CAAb,CAAX;AACA;;AAED,QAAMC,eAAe,GAAGf,eAAe,CAAE,cAAF,CAAvC;AACA,QAAMgB,cAAc,GAAGf,cAAc,EAArC;;AACA,WAASgB,aAAT,CAAwBC,KAAxB,EAAgC;AAC/B,QAAKA,KAAK,CAACC,OAAN,KAAkBZ,MAAlB,IAA4B,CAAEW,KAAK,CAACE,gBAAzC,EAA4D;AAC3DV,MAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;AACD;;AAED,QAAMW,UAAU,GAAGnB,aAAa,CAAEO,eAAF,CAAhC;AACA,QAAMa,OAAO,GAAI,2CAA2CD,UAAY,EAAxE;AAEA,SACC;AACA;AACC,yBAAkBC,OADnB;AAEC,MAAA,SAAS,EAAC,mCAFX;AAGC,MAAA,SAAS,EAAGL;AAHb,OAKC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC;AAAQ,MAAA,EAAE,EAAGK;AAAb,OAAyBjB,EAAE,CAAE,WAAF,CAA3B,CADD,EAEC,cAAC,MAAD;AACC,MAAA,IAAI,EAAGC,UADR;AAEC,MAAA,KAAK,EAAGD,EAAE,CAAE,yBAAF,CAFX;AAGC,MAAA,OAAO,EAAG,MAAMK,mBAAmB,CAAE,KAAF;AAHpC,MAFD,CALD,EAaC;AACC,MAAA,SAAS,EAAC,2CADX;AAEC,MAAA,GAAG,EAAGP,YAAY,CAAE,CAAEa,cAAF,EAAkBD,eAAlB,CAAF;AAFnB,OAIC,cAAC,QAAD;AACC,MAAA,QAAQ,EAAGF,iBADZ;AAEC,MAAA,gBAAgB,MAFjB;AAGC,MAAA,sBAAsB,MAHvB;AAIC,MAAA,wCAAwC;AAJzC,MAJD,CAbD;AAFD;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalListView as ListView,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport {\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseInstanceId,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\tconst { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );\n\tasync function selectEditorBlock( clientId ) {\n\t\tawait clearSelectedBlock();\n\t\tselectBlock( clientId, -1 );\n\t}\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst focusReturnRef = useFocusReturn();\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( ListViewSidebar );\n\tconst labelId = `edit-site-editor__list-view-panel-label-${ instanceId }`;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\taria-labelledby={ labelId }\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div className=\"edit-site-editor__list-view-panel-header\">\n\t\t\t\t<strong id={ labelId }>{ __( 'List view' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close list view sidebar' ) }\n\t\t\t\t\tonClick={ () => setIsListViewOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [ focusReturnRef, focusOnMountRef ] ) }\n\t\t\t>\n\t\t\t\t<ListView\n\t\t\t\t\tonSelect={ selectEditorBlock }\n\t\t\t\t\tshowNestedBlocks\n\t\t\t\t\t__experimentalFeatures\n\t\t\t\t\t__experimentalPersistentListViewFeatures\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"names":["__experimentalListView","ListView","store","blockEditorStore","Button","useFocusOnMount","useFocusReturn","useInstanceId","useMergeRefs","useDispatch","__","closeSmall","ESCAPE","editSiteStore","ListViewSidebar","setIsListViewOpened","clearSelectedBlock","selectBlock","selectEditorBlock","clientId","focusOnMountRef","headerFocusReturnRef","contentFocusReturnRef","closeOnEscape","event","keyCode","defaultPrevented","instanceId","labelId"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,sBAAsB,IAAIC,QAD3B,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SACCC,eADD,EAECC,cAFD,EAGCC,aAHD,EAICC,YAJD,QAKO,oBALP;AAMA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,UAAT,QAA2B,kBAA3B;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASV,KAAK,IAAIW,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,eAAT,GAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAA0BN,WAAW,CAAEI,aAAF,CAA3C;AAEA,QAAM;AAAEG,IAAAA,kBAAF;AAAsBC,IAAAA;AAAtB,MAAsCR,WAAW,CAAEN,gBAAF,CAAvD;;AACA,iBAAee,iBAAf,CAAkCC,QAAlC,EAA6C;AAC5C,UAAMH,kBAAkB,EAAxB;AACAC,IAAAA,WAAW,CAAEE,QAAF,EAAY,CAAC,CAAb,CAAX;AACA;;AAED,QAAMC,eAAe,GAAGf,eAAe,CAAE,cAAF,CAAvC;AACA,QAAMgB,oBAAoB,GAAGf,cAAc,EAA3C;AACA,QAAMgB,qBAAqB,GAAGhB,cAAc,EAA5C;;AACA,WAASiB,aAAT,CAAwBC,KAAxB,EAAgC;AAC/B,QAAKA,KAAK,CAACC,OAAN,KAAkBb,MAAlB,IAA4B,CAAEY,KAAK,CAACE,gBAAzC,EAA4D;AAC3DX,MAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACA;AACD;;AAED,QAAMY,UAAU,GAAGpB,aAAa,CAAEO,eAAF,CAAhC;AACA,QAAMc,OAAO,GAAI,2CAA2CD,UAAY,EAAxE;AAEA,SACC;AACA;AACC,yBAAkBC,OADnB;AAEC,MAAA,SAAS,EAAC,mCAFX;AAGC,MAAA,SAAS,EAAGL;AAHb,OAKC;AACC,MAAA,SAAS,EAAC,0CADX;AAEC,MAAA,GAAG,EAAGF;AAFP,OAIC;AAAQ,MAAA,EAAE,EAAGO;AAAb,OAAyBlB,EAAE,CAAE,WAAF,CAA3B,CAJD,EAKC,cAAC,MAAD;AACC,MAAA,IAAI,EAAGC,UADR;AAEC,MAAA,KAAK,EAAGD,EAAE,CAAE,yBAAF,CAFX;AAGC,MAAA,OAAO,EAAG,MAAMK,mBAAmB,CAAE,KAAF;AAHpC,MALD,CALD,EAgBC;AACC,MAAA,SAAS,EAAC,2CADX;AAEC,MAAA,GAAG,EAAGP,YAAY,CAAE,CACnBc,qBADmB,EAEnBF,eAFmB,CAAF;AAFnB,OAOC,cAAC,QAAD;AACC,MAAA,QAAQ,EAAGF,iBADZ;AAEC,MAAA,gBAAgB,MAFjB;AAGC,MAAA,sBAAsB,MAHvB;AAIC,MAAA,wCAAwC;AAJzC,MAPD,CAhBD;AAFD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalListView as ListView,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport {\n\tuseFocusOnMount,\n\tuseFocusReturn,\n\tuseInstanceId,\n\tuseMergeRefs,\n} from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\n\nexport default function ListViewSidebar() {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\tconst { clearSelectedBlock, selectBlock } = useDispatch( blockEditorStore );\n\tasync function selectEditorBlock( clientId ) {\n\t\tawait clearSelectedBlock();\n\t\tselectBlock( clientId, -1 );\n\t}\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\tconst headerFocusReturnRef = useFocusReturn();\n\tconst contentFocusReturnRef = useFocusReturn();\n\tfunction closeOnEscape( event ) {\n\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\tsetIsListViewOpened( false );\n\t\t}\n\t}\n\n\tconst instanceId = useInstanceId( ListViewSidebar );\n\tconst labelId = `edit-site-editor__list-view-panel-label-${ instanceId }`;\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\taria-labelledby={ labelId }\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-header\"\n\t\t\t\tref={ headerFocusReturnRef }\n\t\t\t>\n\t\t\t\t<strong id={ labelId }>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close List View Sidebar' ) }\n\t\t\t\t\tonClick={ () => setIsListViewOpened( false ) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tcontentFocusReturnRef,\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<ListView\n\t\t\t\t\tonSelect={ selectEditorBlock }\n\t\t\t\t\tshowNestedBlocks\n\t\t\t\t\t__experimentalFeatures\n\t\t\t\t\t__experimentalPersistentListViewFeatures\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -13,7 +13,8 @@ export default function DefaultSidebar(_ref) {
13
13
  children,
14
14
  closeLabel,
15
15
  header,
16
- headerClassName
16
+ headerClassName,
17
+ panelClassName
17
18
  } = _ref;
18
19
  return createElement(Fragment, null, createElement(ComplementaryArea, {
19
20
  className: className,
@@ -23,7 +24,8 @@ export default function DefaultSidebar(_ref) {
23
24
  icon: icon,
24
25
  closeLabel: closeLabel,
25
26
  header: header,
26
- headerClassName: headerClassName
27
+ headerClassName: headerClassName,
28
+ panelClassName: panelClassName
27
29
  }, children), createElement(ComplementaryAreaMoreMenuItem, {
28
30
  scope: "core/edit-site",
29
31
  identifier: identifier,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/default-sidebar.js"],"names":["ComplementaryArea","ComplementaryAreaMoreMenuItem","DefaultSidebar","className","identifier","title","icon","children","closeLabel","header","headerClassName"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,6BAFD,QAGO,sBAHP;AAKA,eAAe,SAASC,cAAT,OASX;AAAA,MAToC;AACvCC,IAAAA,SADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,KAHuC;AAIvCC,IAAAA,IAJuC;AAKvCC,IAAAA,QALuC;AAMvCC,IAAAA,UANuC;AAOvCC,IAAAA,MAPuC;AAQvCC,IAAAA;AARuC,GASpC;AACH,SACC,8BACC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAGP,SADb;AAEC,IAAA,KAAK,EAAC,gBAFP;AAGC,IAAA,UAAU,EAAGC,UAHd;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,IAAI,EAAGC,IALR;AAMC,IAAA,UAAU,EAAGE,UANd;AAOC,IAAA,MAAM,EAAGC,MAPV;AAQC,IAAA,eAAe,EAAGC;AARnB,KAUGH,QAVH,CADD,EAaC,cAAC,6BAAD;AACC,IAAA,KAAK,EAAC,gBADP;AAEC,IAAA,UAAU,EAAGH,UAFd;AAGC,IAAA,IAAI,EAAGE;AAHR,KAKGD,KALH,CAbD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tComplementaryArea,\n\tComplementaryAreaMoreMenuItem,\n} from '@wordpress/interface';\n\nexport default function DefaultSidebar( {\n\tclassName,\n\tidentifier,\n\ttitle,\n\ticon,\n\tchildren,\n\tcloseLabel,\n\theader,\n\theaderClassName,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<ComplementaryArea\n\t\t\t\tclassName={ className }\n\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ttitle={ title }\n\t\t\t\ticon={ icon }\n\t\t\t\tcloseLabel={ closeLabel }\n\t\t\t\theader={ header }\n\t\t\t\theaderClassName={ headerClassName }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</ComplementaryArea>\n\t\t\t<ComplementaryAreaMoreMenuItem\n\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ticon={ icon }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</ComplementaryAreaMoreMenuItem>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/default-sidebar.js"],"names":["ComplementaryArea","ComplementaryAreaMoreMenuItem","DefaultSidebar","className","identifier","title","icon","children","closeLabel","header","headerClassName","panelClassName"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,6BAFD,QAGO,sBAHP;AAKA,eAAe,SAASC,cAAT,OAUX;AAAA,MAVoC;AACvCC,IAAAA,SADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,KAHuC;AAIvCC,IAAAA,IAJuC;AAKvCC,IAAAA,QALuC;AAMvCC,IAAAA,UANuC;AAOvCC,IAAAA,MAPuC;AAQvCC,IAAAA,eARuC;AASvCC,IAAAA;AATuC,GAUpC;AACH,SACC,8BACC,cAAC,iBAAD;AACC,IAAA,SAAS,EAAGR,SADb;AAEC,IAAA,KAAK,EAAC,gBAFP;AAGC,IAAA,UAAU,EAAGC,UAHd;AAIC,IAAA,KAAK,EAAGC,KAJT;AAKC,IAAA,IAAI,EAAGC,IALR;AAMC,IAAA,UAAU,EAAGE,UANd;AAOC,IAAA,MAAM,EAAGC,MAPV;AAQC,IAAA,eAAe,EAAGC,eARnB;AASC,IAAA,cAAc,EAAGC;AATlB,KAWGJ,QAXH,CADD,EAcC,cAAC,6BAAD;AACC,IAAA,KAAK,EAAC,gBADP;AAEC,IAAA,UAAU,EAAGH,UAFd;AAGC,IAAA,IAAI,EAAGE;AAHR,KAKGD,KALH,CAdD,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tComplementaryArea,\n\tComplementaryAreaMoreMenuItem,\n} from '@wordpress/interface';\n\nexport default function DefaultSidebar( {\n\tclassName,\n\tidentifier,\n\ttitle,\n\ticon,\n\tchildren,\n\tcloseLabel,\n\theader,\n\theaderClassName,\n\tpanelClassName,\n} ) {\n\treturn (\n\t\t<>\n\t\t\t<ComplementaryArea\n\t\t\t\tclassName={ className }\n\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ttitle={ title }\n\t\t\t\ticon={ icon }\n\t\t\t\tcloseLabel={ closeLabel }\n\t\t\t\theader={ header }\n\t\t\t\theaderClassName={ headerClassName }\n\t\t\t\tpanelClassName={ panelClassName }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</ComplementaryArea>\n\t\t\t<ComplementaryAreaMoreMenuItem\n\t\t\t\tscope=\"core/edit-site\"\n\t\t\t\tidentifier={ identifier }\n\t\t\t\ticon={ icon }\n\t\t\t>\n\t\t\t\t{ title }\n\t\t\t</ComplementaryAreaMoreMenuItem>\n\t\t</>\n\t);\n}\n"]}
@@ -25,6 +25,7 @@ export default function GlobalStylesSidebar() {
25
25
  title: __('Styles'),
26
26
  icon: styles,
27
27
  closeLabel: __('Close global styles sidebar'),
28
+ panelClassName: "edit-site-global-styles-sidebar__panel",
28
29
  header: createElement(Flex, null, createElement(FlexBlock, null, createElement("strong", null, __('Styles')), createElement("span", {
29
30
  className: "edit-site-global-styles-sidebar__beta"
30
31
  }, __('Beta'))), createElement(FlexItem, null, createElement(DropdownMenu, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["DropdownMenu","FlexItem","FlexBlock","Flex","__","styles","moreVertical","useDispatch","DefaultSidebar","GlobalStylesUI","useGlobalStylesReset","store","editSiteStore","GlobalStylesSidebar","canReset","onReset","toggleFeature","disabled","title","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,IAA5C,QAAwD,uBAAxD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,YAAjB,QAAqC,kBAArC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,mBAA3B;AACA,SAASC,cAAT,EAAyBC,oBAAzB,QAAqD,kBAArD;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,mBAAT,GAA+B;AAC7C,QAAM,CAAEC,QAAF,EAAYC,OAAZ,IAAwBL,oBAAoB,EAAlD;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAoBT,WAAW,CAAEK,aAAF,CAArC;AAEA,SACC,cAAC,cAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,UAAU,EAAC,yBAFZ;AAGC,IAAA,KAAK,EAAGR,EAAE,CAAE,QAAF,CAHX;AAIC,IAAA,IAAI,EAAGC,MAJR;AAKC,IAAA,UAAU,EAAGD,EAAE,CAAE,6BAAF,CALhB;AAMC,IAAA,MAAM,EACL,cAAC,IAAD,QACC,cAAC,SAAD,QACC,8BAAUA,EAAE,CAAE,QAAF,CAAZ,CADD,EAEC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACGA,EAAE,CAAE,MAAF,CADL,CAFD,CADD,EAOC,cAAC,QAAD,QACC,cAAC,YAAD;AACC,MAAA,IAAI,EAAGE,YADR;AAEC,MAAA,KAAK,EAAGF,EAAE,CAAE,4BAAF,CAFX;AAGC,MAAA,WAAW,EAAG;AAAEa,QAAAA,QAAQ,EAAE,CAAEH;AAAd,OAHf;AAIC,MAAA,QAAQ,EAAG,CACV;AACCI,QAAAA,KAAK,EAAEd,EAAE,CAAE,mBAAF,CADV;AAECe,QAAAA,OAAO,EAAEJ;AAFV,OADU,EAKV;AACCG,QAAAA,KAAK,EAAEd,EAAE,CAAE,eAAF,CADV;AAECe,QAAAA,OAAO,EAAE,MACRH,aAAa,CAAE,oBAAF;AAHf,OALU;AAJZ,MADD,CAPD;AAPF,KAmCC,cAAC,cAAD,OAnCD,CADD;AAuCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, moreVertical } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';\nimport { store as editSiteStore } from '../../store';\n\nexport default function GlobalStylesSidebar() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-global-styles-sidebar\"\n\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\ticon={ styles }\n\t\t\tcloseLabel={ __( 'Close global styles sidebar' ) }\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Styles' ) }</strong>\n\t\t\t\t\t\t<span className=\"edit-site-global-styles-sidebar__beta\">\n\t\t\t\t\t\t\t{ __( 'Beta' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'More Global Styles Actions' ) }\n\t\t\t\t\t\t\ttoggleProps={ { disabled: ! canReset } }\n\t\t\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Reset to defaults' ),\n\t\t\t\t\t\t\t\t\tonClick: onReset,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Welcome Guide' ),\n\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\ttoggleFeature( 'welcomeGuideStyles' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<GlobalStylesUI />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/global-styles-sidebar.js"],"names":["DropdownMenu","FlexItem","FlexBlock","Flex","__","styles","moreVertical","useDispatch","DefaultSidebar","GlobalStylesUI","useGlobalStylesReset","store","editSiteStore","GlobalStylesSidebar","canReset","onReset","toggleFeature","disabled","title","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,EAA4CC,IAA5C,QAAwD,uBAAxD;AACA,SA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,oBAAF;AAHf,OALU;AAJZ,MADD,CAPD;AARF,KAoCC,cAAC,cAAD,OApCD,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu, FlexItem, FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { styles, moreVertical } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport { GlobalStylesUI, useGlobalStylesReset } from '../global-styles';\nimport { store as editSiteStore } from '../../store';\n\nexport default function GlobalStylesSidebar() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst { toggleFeature } = useDispatch( editSiteStore );\n\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-global-styles-sidebar\"\n\t\t\tidentifier=\"edit-site/global-styles\"\n\t\t\ttitle={ __( 'Styles' ) }\n\t\t\ticon={ styles }\n\t\t\tcloseLabel={ __( 'Close global styles sidebar' ) }\n\t\t\tpanelClassName=\"edit-site-global-styles-sidebar__panel\"\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Styles' ) }</strong>\n\t\t\t\t\t\t<span className=\"edit-site-global-styles-sidebar__beta\">\n\t\t\t\t\t\t\t{ __( 'Beta' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'More Global Styles Actions' ) }\n\t\t\t\t\t\t\ttoggleProps={ { disabled: ! canReset } }\n\t\t\t\t\t\t\tcontrols={ [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Reset to defaults' ),\n\t\t\t\t\t\t\t\t\tonClick: onReset,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ttitle: __( 'Welcome Guide' ),\n\t\t\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\t\t\ttoggleFeature( 'welcomeGuideStyles' ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<GlobalStylesUI />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
@@ -2,36 +2,27 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useEffect } from '@wordpress/element';
5
- import { useDispatch, useSelect } from '@wordpress/data';
5
+ import { useDispatch } from '@wordpress/data';
6
6
  /**
7
7
  * Internal dependencies
8
8
  */
9
9
 
10
- import { useLocation, useHistory } from '../routes';
10
+ import { useLocation } from '../routes';
11
11
  import { store as editSiteStore } from '../../store';
12
12
  export default function URLQueryController() {
13
13
  const {
14
14
  setTemplate,
15
15
  setTemplatePart,
16
- showHomepage,
17
16
  setPage
18
17
  } = useDispatch(editSiteStore);
19
- const history = useHistory();
20
18
  const {
21
19
  params: {
22
20
  postId,
23
21
  postType
24
22
  }
25
- } = useLocation();
26
- const {
27
- getPage,
28
- getEditedPostId,
29
- getEditedPostType
30
- } = useSelect(editSiteStore); // Set correct entity on page navigation.
23
+ } = useLocation(); // Set correct entity on page navigation.
31
24
 
32
25
  useEffect(() => {
33
- let isMounted = true;
34
-
35
26
  if ('page' === postType || 'post' === postType) {
36
27
  setPage({
37
28
  context: {
@@ -43,35 +34,7 @@ export default function URLQueryController() {
43
34
  setTemplate(postId);
44
35
  } else if ('wp_template_part' === postType) {
45
36
  setTemplatePart(postId);
46
- } else {
47
- showHomepage().then(() => {
48
- var _page$context, _page$context2;
49
-
50
- if (!isMounted) {
51
- return;
52
- }
53
-
54
- const page = getPage();
55
- const editedPostId = getEditedPostId();
56
- const editedPostType = getEditedPostType();
57
-
58
- 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) {
59
- history.replace({
60
- postId: page.context.postId,
61
- postType: page.context.postType
62
- });
63
- } else if (editedPostId && editedPostType) {
64
- history.replace({
65
- postId: editedPostId,
66
- postType: editedPostType
67
- });
68
- }
69
- });
70
37
  }
71
-
72
- return () => {
73
- isMounted = false;
74
- };
75
38
  }, [postId, postType]);
76
39
  return null;
77
40
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/url-query-controller/index.js"],"names":["useEffect","useDispatch","useSelect","useLocation","useHistory","store","editSiteStore","URLQueryController","setTemplate","setTemplatePart","showHomepage","setPage","history","params","postId","postType","getPage","getEditedPostId","getEditedPostType","isMounted","context","then","page","editedPostId","editedPostType","replace"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,UAAtB,QAAwC,WAAxC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA,YAAhC;AAA8CC,IAAAA;AAA9C,MAA0DV,WAAW,CAC1EK,aAD0E,CAA3E;AAGA,QAAMM,OAAO,GAAGR,UAAU,EAA1B;AACA,QAAM;AACLS,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEFZ,WAAW,EAFf;AAGA,QAAM;AAAEa,IAAAA,OAAF;AAAWC,IAAAA,eAAX;AAA4BC,IAAAA;AAA5B,MAAkDhB,SAAS,CAChEI,aADgE,CAAjE,CAR4C,CAY5C;;AACAN,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAIm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CN,CAAEL,MAAF,EAAUC,QAAV,CApCM,CAAT;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":["useEffect","useDispatch","useLocation","store","editSiteStore","URLQueryController","setTemplate","setTemplatePart","setPage","params","postId","postType","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,WAA5B;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,aAAvC;AAEA,eAAe,SAASC,kBAAT,GAA8B;AAC5C,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,eAAf;AAAgCC,IAAAA;AAAhC,MAA4CP,WAAW,CAC5DG,aAD4D,CAA7D;AAGA,QAAM;AACLK,IAAAA,MAAM,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AADH,MAEFT,WAAW,EAFf,CAJ4C,CAQ5C;;AACAF,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAK,WAAWW,QAAX,IAAuB,WAAWA,QAAvC,EAAkD;AACjDH,MAAAA,OAAO,CAAE;AAAEI,QAAAA,OAAO,EAAE;AAAED,UAAAA,QAAF;AAAYD,UAAAA;AAAZ;AAAX,OAAF,CAAP,CADiD,CACH;AAC9C,KAFD,MAEO,IAAK,kBAAkBC,QAAvB,EAAkC;AACxCL,MAAAA,WAAW,CAAEI,MAAF,CAAX;AACA,KAFM,MAEA,IAAK,uBAAuBC,QAA5B,EAAuC;AAC7CJ,MAAAA,eAAe,CAAEG,MAAF,CAAf;AACA;AACD,GARQ,EAQN,CAAEA,MAAF,EAAUC,QAAV,CARM,CAAT;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"]}
@@ -15,11 +15,11 @@ import { getQueryArgs } from '@wordpress/url';
15
15
  * Internal dependencies
16
16
  */
17
17
 
18
- import './plugins';
19
18
  import './hooks';
20
19
  import { store as editSiteStore } from './store';
21
20
  import EditSiteApp from './components/app';
22
21
  import getIsListPage from './utils/get-is-list-page';
22
+ import redirectToHomepage from './components/routes/redirect-to-homepage';
23
23
  /**
24
24
  * Reinitializes the editor after the user chooses to reboot the editor after
25
25
  * an unhandled error occurs, replacing previously mounted editor element using
@@ -29,8 +29,13 @@ import getIsListPage from './utils/get-is-list-page';
29
29
  * @param {?Object} settings Editor settings object.
30
30
  */
31
31
 
32
- export function reinitializeEditor(target, settings) {
33
- // This will be a no-op if the target doesn't have any React nodes.
32
+ export async function reinitializeEditor(target, settings) {
33
+ // The site editor relies on `postType` and `postId` params in the URL to
34
+ // define what's being edited. When visiting via the dashboard link, these
35
+ // won't be present. Do a client side redirect to the 'homepage' if that's
36
+ // the case.
37
+ await redirectToHomepage(settings.siteUrl); // This will be a no-op if the target doesn't have any React nodes.
38
+
34
39
  unmountComponentAtNode(target);
35
40
  const reboot = reinitializeEditor.bind(null, target, settings); // We dispatch actions and update the store synchronously before rendering
36
41
  // so that we won't trigger unnecessary re-renders with useEffect.
@@ -75,7 +80,7 @@ export function initializeEditor(id, settings) {
75
80
 
76
81
  registerCoreBlocks();
77
82
 
78
- if (process.env.GUTENBERG_PHASE === 2) {
83
+ if (process.env.IS_GUTENBERG_PLUGIN) {
79
84
  __experimentalRegisterExperimentalCoreBlocks({
80
85
  enableFSEBlocks: true
81
86
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","select","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","viewportStore","getQueryArgs","editSiteStore","EditSiteApp","getIsListPage","reinitializeEditor","target","settings","reboot","bind","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","isViewportMatch","initializeEditor","id","search","searchOptions","__experimentalFetchRichUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SACCC,kCAAkC,IAAIC,oBADvC,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,sBAHP;AAIA,SAASX,KAAK,IAAIY,WAAlB,QAAqC,mBAArC;AACA,SAASZ,KAAK,IAAIa,aAAlB,QAAuC,qBAAvC;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,OAAO,WAAP;AACA,OAAO,SAAP;AACA,SAASd,KAAK,IAAIe,aAAlB,QAAuC,SAAvC;AACA,OAAOC,WAAP,MAAwB,kBAAxB;AACA,OAAOC,aAAP,MAA0B,0BAA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AAA,QAAQ,CAACkB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMnB,MAAM,GAAGoB,QAAQ,CAACC,cAAT,CAAyBN,EAAzB,CAAf;;AAEA9B,EAAAA,QAAQ,CAAEH,WAAF,CAAR,CAAwBwC,qCAAxB;;AACAvC,EAAAA,kBAAkB;;AAClB,MAAKwC,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxCzC,IAAAA,4CAA4C,CAAE;AAC7C0C,MAAAA,eAAe,EAAE;AAD4B,KAAF,CAA5C;AAGA;;AAED3B,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA;AAED,SAAS0B,OAAO,IAAIC,iCAApB,QAA6D,oCAA7D;AACA,SAASD,OAAO,IAAIE,8BAApB,QAA0D,mDAA1D;AACA,SAASF,OAAO,IAAIG,aAApB,QAAyC,qCAAzC;AACA,SAASH,OAAO,IAAII,yBAApB,QAAqD,mDAArD;AACA,SAASJ,OAAO,IAAIK,kBAApB,QAA8C,2CAA9C","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":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","dispatch","select","render","unmountComponentAtNode","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","editorStore","viewportStore","getQueryArgs","editSiteStore","EditSiteApp","getIsListPage","redirectToHomepage","reinitializeEditor","target","settings","siteUrl","reboot","bind","updateSettings","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","isViewportMatch","initializeEditor","id","search","searchOptions","__experimentalFetchRichUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","default","__experimentalMainDashboardButton","__experimentalNavigationToggle","PluginSidebar","PluginSidebarMoreMenuItem","PluginMoreMenuItem"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SACCC,kBADD,EAECC,4CAFD,QAGO,0BAHP;AAIA,SAASC,QAAT,EAAmBC,MAAnB,QAAiC,iBAAjC;AACA,SAASC,MAAT,EAAiBC,sBAAjB,QAA+C,oBAA/C;AACA,SACCC,kCAAkC,IAAIC,oBADvC,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,sBAHP;AAIA,SAASX,KAAK,IAAIY,WAAlB,QAAqC,m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AAAa,IAAA,MAAM,EAAGiB;AAAtB,IAAF,EAAqCH,MAArC,CAAN;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASe,gBAAT,CAA2BC,EAA3B,EAA+Bf,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAACb,kCAAT,GAA8C,CAAE6B,MAAF,EAAUC,aAAV,KAC7C7B,oBAAoB,CAAE4B,MAAF,EAAUC,aAAV,EAAyBjB,QAAzB,CADrB;;AAEAA,EAAAA,QAAQ,CAACkB,8BAAT,GAA0C5B,YAA1C;AACAU,EAAAA,QAAQ,CAACmB,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMpB,MAAM,GAAGqB,QAAQ,CAACC,cAAT,CAAyBN,EAAzB,CAAf;;AAEAhC,EAAAA,QAAQ,CAAEH,WAAF,CAAR,CAAwB0C,qCAAxB;;AACAzC,EAAAA,kBAAkB;;AAClB,MAAK0C,OAAO,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtC3C,IAAAA,4CAA4C,CAAE;AAC7C4C,MAAAA,eAAe,EAAE;AAD4B,KAAF,CAA5C;AAGA;;AAED5B,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA;AAED,SAAS2B,OAAO,IAAIC,iCAApB,QAA6D,oCAA7D;AACA,SAASD,OAAO,IAAIE,8BAApB,QAA0D,mDAA1D;AACA,SAASF,OAAO,IAAIG,aAApB,QAAyC,qCAAzC;AACA,SAASH,OAAO,IAAII,yBAApB,QAAqD,mDAArD;AACA,SAASJ,OAAO,IAAIK,kBAApB,QAA8C,2CAA9C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\nimport redirectToHomepage from './components/routes/redirect-to-homepage';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport async function reinitializeEditor( target, settings ) {\n\t// The site editor relies on `postType` and `postId` params in the URL to\n\t// define what's being edited. When visiting via the dashboard link, these\n\t// won't be present. Do a client side redirect to the 'homepage' if that's\n\t// the case.\n\tawait redirectToHomepage( settings.siteUrl );\n\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
@@ -9,6 +9,8 @@ import { __, sprintf } from '@wordpress/i18n';
9
9
  import { store as noticesStore } from '@wordpress/notices';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
11
  import { store as interfaceStore } from '@wordpress/interface';
12
+ import { store as blockEditorStore } from '@wordpress/block-editor';
13
+ import { speak } from '@wordpress/a11y';
12
14
  /**
13
15
  * Internal dependencies
14
16
  */
@@ -117,7 +119,7 @@ export function* removeTemplate(template) {
117
119
 
118
120
  yield controls.dispatch(noticesStore, 'createSuccessNotice', sprintf(
119
121
  /* translators: The template/part's name. */
120
- __('"%s" removed.'), template.title.rendered), {
122
+ __('"%s" deleted.'), template.title.rendered), {
121
123
  type: 'snackbar'
122
124
  });
123
125
  } catch (error) {
@@ -171,8 +173,9 @@ export function* setPage(page) {
171
173
  var _page$context;
172
174
 
173
175
  if (!page.path && (_page$context = page.context) !== null && _page$context !== void 0 && _page$context.postId) {
174
- const entity = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', page.context.postType || 'post', page.context.postId);
175
- page.path = getPathAndQueryString(entity.link);
176
+ const entity = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'postType', page.context.postType || 'post', page.context.postId); // If the entity is undefined for some reason, path will resolve to "/"
177
+
178
+ page.path = getPathAndQueryString(entity === null || entity === void 0 ? void 0 : entity.link);
176
179
  }
177
180
 
178
181
  const {
@@ -190,28 +193,6 @@ export function* setPage(page) {
190
193
  };
191
194
  return templateId;
192
195
  }
193
- /**
194
- * Displays the site homepage for editing in the editor.
195
- */
196
-
197
- export function* showHomepage() {
198
- const {
199
- show_on_front: showOnFront,
200
- page_on_front: frontpageId
201
- } = yield controls.resolveSelect(coreStore, 'getEntityRecord', 'root', 'site');
202
- const {
203
- siteUrl
204
- } = yield controls.select(editSiteStoreName, 'getSettings');
205
- const page = {
206
- path: siteUrl,
207
- context: showOnFront === 'page' ? {
208
- postType: 'page',
209
- postId: frontpageId
210
- } : {}
211
- };
212
- const homeTemplate = yield* setPage(page);
213
- yield setHomeTemplateId(homeTemplate);
214
- }
215
196
  /**
216
197
  * Returns an action object used to set the active navigation panel menu.
217
198
  *
@@ -419,4 +400,23 @@ export function* openGeneralSidebar(name) {
419
400
  export function* closeGeneralSidebar() {
420
401
  yield controls.dispatch(interfaceStore, 'disableComplementaryArea', editSiteStoreName);
421
402
  }
403
+ export function* switchEditorMode(mode) {
404
+ yield {
405
+ type: 'SWITCH_MODE',
406
+ mode
407
+ }; // Unselect blocks when we switch to a non visual mode.
408
+
409
+ if (mode !== 'visual') {
410
+ yield controls.dispatch(blockEditorStore.name, 'clearSelectedBlock');
411
+ }
412
+
413
+ const messages = {
414
+ visual: __('Visual editor selected'),
415
+ mosaic: __('Mosaic view selected')
416
+ };
417
+
418
+ if (messages[mode]) {
419
+ speak(messages[mode], 'assertive');
420
+ }
421
+ }
422
422
  //# sourceMappingURL=actions.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["parse","__unstableSerializeAndClean","controls","dispatch","apiFetch","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","resolveSelect","slug","page","context","addTemplate","newTemplate","content","id","blocks","undoIgnore","removeTemplate","force","lastError","select","title","rendered","error","errorMessage","message","code","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","showHomepage","show_on_front","showOnFront","page_on_front","frontpageId","siteUrl","homeTemplate","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","openGeneralSidebar","name","closeGeneralSidebar"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,iBAAnC;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AA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AAML,QAAQ,CAACC,QAAT,CACLO,YADK,EAEL,mBAFK,EAGLiC,YAHK,EAIL;AAAEzB,MAAAA,IAAI,EAAE;AAAR,KAJK,CAAN;AAMA;AACD;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUuE,kBAAV,CAA8BC,IAA9B,EAAqC;AAC3C,QAAMxF,QAAQ,CAACC,QAAT,CACLS,cADK,EAEL,yBAFK,EAGLE,iBAHK,EAIL4E,IAJK,CAAN;AAMA;AAED;AACA;AACA;AACA;AACA;;AACA,OAAO,UAAUC,mBAAV,GAAgC;AACtC,QAAMzF,QAAQ,CAACC,QAAT,CACLS,cADK,EAEL,0BAFK,EAGLE,iBAHK,CAAN;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * Adds a new template, and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\ttry {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'deleteEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{ force: true }\n\t\t);\n\n\t\tconst lastError = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getLastEntityDeleteError',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" removed.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\n\t\tpage.path = getPathAndQueryString( entity.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Displays the site homepage for editing in the editor.\n */\nexport function* showHomepage() {\n\tconst {\n\t\tshow_on_front: showOnFront,\n\t\tpage_on_front: frontpageId,\n\t} = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'getEntityRecord',\n\t\t'root',\n\t\t'site'\n\t);\n\n\tconst { siteUrl } = yield controls.select(\n\t\teditSiteStoreName,\n\t\t'getSettings'\n\t);\n\n\tconst page = {\n\t\tpath: siteUrl,\n\t\tcontext:\n\t\t\tshowOnFront === 'page'\n\t\t\t\t? {\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: frontpageId,\n\t\t\t\t }\n\t\t\t\t: {},\n\t};\n\n\tconst homeTemplate = yield* setPage( page );\n\tyield setHomeTemplateId( homeTemplate );\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport function* revertTemplate( template, { allowUndo = true } = {} ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = async () => {\n\t\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' )\n\t\t\t);\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/actions.js"],"names":["parse","__unstableSerializeAndClean","controls","dispatch","apiFetch","addQueryArgs","getPathAndQueryString","__","sprintf","store","noticesStore","coreStore","interfaceStore","blockEditorStore","speak","STORE_NAME","editSiteStoreName","isTemplateRevertable","toggleFeature","feature","type","__experimentalSetPreviewDeviceType","deviceType","setTemplate","templateId","templateSlug","pageContext","template","resolveSelect","slug","page","context","addTemplate","newTemplate","content","id","blocks","undoIgnore","removeTemplate","force","lastError","select","title","rendered","error","errorMessage","message","code","setTemplatePart","templatePartId","setHomeTemplateId","homeTemplateId","setPage","path","postId","entity","postType","link","setNavigationPanelActiveMenu","menu","openNavigationPanelToMenu","setIsNavigationPanelOpened","isOpen","setIsInserterOpened","value","updateSettings","settings","setIsListViewOpened","revertTemplate","allowUndo","templateEntity","fileTemplatePath","baseURL","source","fileTemplate","serializeBlocks","blocksForSerialization","edited","raw","undoRevert","editEntityRecord","actions","label","onClick","openGeneralSidebar","name","closeGeneralSidebar","switchEditorMode","mode","messages","visual","mosaic"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAT,EAAgBC,2BAAhB,QAAmD,mBAAnD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,iBAAnC;AACA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,YAAT,EAAuBC,qBAAvB,QAAoD,gBAApD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,cAAlB,QAAwC,sBAAxC;AACA,SAASH,KAAK,IAAII,gBAAlB,QAA0C,yBAA1C;AACA,SAAS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ADD;AAELoE,IAAAA;AAFK,GAAN,CADyC,CAMzC;;AACA,MAAKA,IAAI,KAAK,QAAd,EAAyB;AACxB,UAAMtF,QAAQ,CAACC,QAAT,CAAmBU,gBAAgB,CAACwE,IAApC,EAA0C,oBAA1C,CAAN;AACA;;AACD,QAAMI,QAAQ,GAAG;AAChBC,IAAAA,MAAM,EAAEnF,EAAE,CAAE,wBAAF,CADM;AAEhBoF,IAAAA,MAAM,EAAEpF,EAAE,CAAE,sBAAF;AAFM,GAAjB;;AAIA,MAAKkF,QAAQ,CAAED,IAAF,CAAb,EAAwB;AACvB1E,IAAAA,KAAK,CAAE2E,QAAQ,CAAED,IAAF,CAAV,EAAoB,WAApB,CAAL;AACA;AACD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { controls, dispatch } from '@wordpress/data';\nimport { apiFetch } from '@wordpress/data-controls';\nimport { addQueryArgs, getPathAndQueryString } from '@wordpress/url';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME as editSiteStoreName } from './constants';\nimport isTemplateRevertable from '../utils/is-template-revertable';\n\n/**\n * Returns an action object used to toggle a feature flag.\n *\n * @param {string} feature Feature name.\n *\n * @return {Object} Action object.\n */\nexport function toggleFeature( feature ) {\n\treturn {\n\t\ttype: 'TOGGLE_FEATURE',\n\t\tfeature,\n\t};\n}\n\n/**\n * Returns an action object used to toggle the width of the editing canvas.\n *\n * @param {string} deviceType\n *\n * @return {Object} Action object.\n */\nexport function __experimentalSetPreviewDeviceType( deviceType ) {\n\treturn {\n\t\ttype: 'SET_PREVIEW_DEVICE_TYPE',\n\t\tdeviceType,\n\t};\n}\n\n/**\n * Returns an action object used to set a template.\n *\n * @param {number} templateId The template ID.\n * @param {string} templateSlug The template slug.\n * @return {Object} Action object.\n */\nexport function* setTemplate( templateId, templateSlug ) {\n\tconst pageContext = { templateSlug };\n\tif ( ! templateSlug ) {\n\t\tconst template = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t\tpageContext.templateSlug = template?.slug;\n\t}\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId,\n\t\tpage: { context: pageContext },\n\t};\n}\n\n/**\n * Adds a new template, and sets it as the current template.\n *\n * @param {Object} template The template.\n *\n * @return {Object} Action object used to set the current template.\n */\nexport function* addTemplate( template ) {\n\tconst newTemplate = yield controls.dispatch(\n\t\tcoreStore,\n\t\t'saveEntityRecord',\n\t\t'postType',\n\t\t'wp_template',\n\t\ttemplate\n\t);\n\n\tif ( template.content ) {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\tnewTemplate.id,\n\t\t\t{ blocks: parse( template.content ) },\n\t\t\t{ undoIgnore: true }\n\t\t);\n\t}\n\n\treturn {\n\t\ttype: 'SET_TEMPLATE',\n\t\ttemplateId: newTemplate.id,\n\t\tpage: { context: { templateSlug: newTemplate.slug } },\n\t};\n}\n\n/**\n * Removes a template.\n *\n * @param {Object} template The template object.\n */\nexport function* removeTemplate( template ) {\n\ttry {\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'deleteEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{ force: true }\n\t\t);\n\n\t\tconst lastError = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getLastEntityDeleteError',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\n\t\tif ( lastError ) {\n\t\t\tthrow lastError;\n\t\t}\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createSuccessNotice',\n\t\t\tsprintf(\n\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t__( '\"%s\" deleted.' ),\n\t\t\t\ttemplate.title.rendered\n\t\t\t),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'An error occurred while deleting the template.' );\n\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n\n/**\n * Returns an action object used to set a template part.\n *\n * @param {string} templatePartId The template part ID.\n *\n * @return {Object} Action object.\n */\nexport function setTemplatePart( templatePartId ) {\n\treturn {\n\t\ttype: 'SET_TEMPLATE_PART',\n\t\ttemplatePartId,\n\t};\n}\n\n/**\n * Updates the homeTemplateId state with the templateId of the page resolved\n * from the given path.\n *\n * @param {number} homeTemplateId The template ID for the homepage.\n */\nexport function setHomeTemplateId( homeTemplateId ) {\n\treturn {\n\t\ttype: 'SET_HOME_TEMPLATE',\n\t\thomeTemplateId,\n\t};\n}\n\n/**\n * Resolves the template for a page and displays both. If no path is given, attempts\n * to use the postId to generate a path like `?p=${ postId }`.\n *\n * @param {Object} page The page object.\n * @param {string} page.type The page type.\n * @param {string} page.slug The page slug.\n * @param {string} page.path The page path.\n * @param {Object} page.context The page context.\n *\n * @return {number} The resolved template ID for the page route.\n */\nexport function* setPage( page ) {\n\tif ( ! page.path && page.context?.postId ) {\n\t\tconst entity = yield controls.resolveSelect(\n\t\t\tcoreStore,\n\t\t\t'getEntityRecord',\n\t\t\t'postType',\n\t\t\tpage.context.postType || 'post',\n\t\t\tpage.context.postId\n\t\t);\n\t\t// If the entity is undefined for some reason, path will resolve to \"/\"\n\t\tpage.path = getPathAndQueryString( entity?.link );\n\t}\n\tconst { id: templateId, slug: templateSlug } = yield controls.resolveSelect(\n\t\tcoreStore,\n\t\t'__experimentalGetTemplateForLink',\n\t\tpage.path\n\t);\n\tyield {\n\t\ttype: 'SET_PAGE',\n\t\tpage: ! templateSlug\n\t\t\t? page\n\t\t\t: {\n\t\t\t\t\t...page,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\t...page.context,\n\t\t\t\t\t\ttemplateSlug,\n\t\t\t\t\t},\n\t\t\t },\n\t\ttemplateId,\n\t};\n\treturn templateId;\n}\n\n/**\n * Returns an action object used to set the active navigation panel menu.\n *\n * @param {string} menu Menu prop of active menu.\n *\n * @return {Object} Action object.\n */\nexport function setNavigationPanelActiveMenu( menu ) {\n\treturn {\n\t\ttype: 'SET_NAVIGATION_PANEL_ACTIVE_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Opens the navigation panel and sets its active menu at the same time.\n *\n * @param {string} menu Identifies the menu to open.\n */\nexport function openNavigationPanelToMenu( menu ) {\n\treturn {\n\t\ttype: 'OPEN_NAVIGATION_PANEL_TO_MENU',\n\t\tmenu,\n\t};\n}\n\n/**\n * Sets whether the navigation panel should be open.\n *\n * @param {boolean} isOpen If true, opens the nav panel. If false, closes it. It\n * does not toggle the state, but sets it directly.\n */\nexport function setIsNavigationPanelOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_NAVIGATION_PANEL_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to update the settings.\n *\n * @param {Object} settings New settings.\n *\n * @return {Object} Action object.\n */\nexport function updateSettings( settings ) {\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Sets whether the list view panel should be open.\n *\n * @param {boolean} isOpen If true, opens the list view. If false, closes it.\n * It does not toggle the state, but sets it directly.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport function* revertTemplate( template, { allowUndo = true } = {} ) {\n\tif ( ! isTemplateRevertable( template ) ) {\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\t__( 'This template is not revertable.' ),\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t\treturn;\n\t}\n\n\ttry {\n\t\tconst templateEntity = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEntity',\n\t\t\t'postType',\n\t\t\ttemplate.type\n\t\t);\n\t\tif ( ! templateEntity ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t`${ templateEntity.baseURL }/${ template.id }`,\n\t\t\t{ context: 'edit', source: 'theme' }\n\t\t);\n\t\tconst fileTemplate = yield apiFetch( { path: fileTemplatePath } );\n\t\tif ( ! fileTemplate ) {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createErrorNotice',\n\t\t\t\t__(\n\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t),\n\t\t\t\t{ type: 'snackbar' }\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tconst serializeBlocks = ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t__unstableSerializeAndClean( blocksForSerialization );\n\t\tconst edited = yield controls.select(\n\t\t\tcoreStore,\n\t\t\t'getEditedEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id\n\t\t);\n\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t// the revert in the header toolbar correctly.\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\ttemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks, // required to make the `undo` behave correctly\n\t\t\t\tblocks: edited.blocks, // required to revert the blocks in the editor\n\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t},\n\t\t\t{\n\t\t\t\tundoIgnore: true, // required to merge this edit with the last undo level\n\t\t\t}\n\t\t);\n\n\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\tyield controls.dispatch(\n\t\t\tcoreStore,\n\t\t\t'editEntityRecord',\n\t\t\t'postType',\n\t\t\ttemplate.type,\n\t\t\tfileTemplate.id,\n\t\t\t{\n\t\t\t\tcontent: serializeBlocks,\n\t\t\t\tblocks,\n\t\t\t\tsource: 'theme',\n\t\t\t}\n\t\t);\n\n\t\tif ( allowUndo ) {\n\t\t\tconst undoRevert = async () => {\n\t\t\t\tawait dispatch( coreStore ).editEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tedited.id,\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t};\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: undoRevert,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tyield controls.dispatch(\n\t\t\t\tnoticesStore,\n\t\t\t\t'createSuccessNotice',\n\t\t\t\t__( 'Template reverted.' )\n\t\t\t);\n\t\t}\n\t} catch ( error ) {\n\t\tconst errorMessage =\n\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t? error.message\n\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\tyield controls.dispatch(\n\t\t\tnoticesStore,\n\t\t\t'createErrorNotice',\n\t\t\terrorMessage,\n\t\t\t{ type: 'snackbar' }\n\t\t);\n\t}\n}\n/**\n * Returns an action object used in signalling that the user opened an editor sidebar.\n *\n * @param {?string} name Sidebar name to be opened.\n *\n * @yield {Object} Action object.\n */\nexport function* openGeneralSidebar( name ) {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'enableComplementaryArea',\n\t\teditSiteStoreName,\n\t\tname\n\t);\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @yield {Object} Action object.\n */\nexport function* closeGeneralSidebar() {\n\tyield controls.dispatch(\n\t\tinterfaceStore,\n\t\t'disableComplementaryArea',\n\t\teditSiteStoreName\n\t);\n}\n\nexport function* switchEditorMode( mode ) {\n\tyield {\n\t\ttype: 'SWITCH_MODE',\n\t\tmode,\n\t};\n\n\t// Unselect blocks when we switch to a non visual mode.\n\tif ( mode !== 'visual' ) {\n\t\tyield controls.dispatch( blockEditorStore.name, 'clearSelectedBlock' );\n\t}\n\tconst messages = {\n\t\tvisual: __( 'Visual editor selected' ),\n\t\tmosaic: __( 'Mosaic view selected' ),\n\t};\n\tif ( messages[ mode ] ) {\n\t\tspeak( messages[ mode ], 'assertive' );\n\t}\n}\n"]}
@@ -2,6 +2,7 @@ export const PREFERENCES_DEFAULTS = {
2
2
  features: {
3
3
  welcomeGuide: true,
4
4
  welcomeGuideStyles: true
5
- }
5
+ },
6
+ editorMode: 'visual'
6
7
  };
7
8
  //# sourceMappingURL=defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","features","welcomeGuide","welcomeGuideStyles"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,QAAQ,EAAE;AACTC,IAAAA,YAAY,EAAE,IADL;AAETC,IAAAA,kBAAkB,EAAE;AAFX;AADyB,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\tfeatures: {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/defaults.js"],"names":["PREFERENCES_DEFAULTS","features","welcomeGuide","welcomeGuideStyles","editorMode"],"mappings":"AAAA,OAAO,MAAMA,oBAAoB,GAAG;AACnCC,EAAAA,QAAQ,EAAE;AACTC,IAAAA,YAAY,EAAE,IADL;AAETC,IAAAA,kBAAkB,EAAE;AAFX,GADyB;AAKnCC,EAAAA,UAAU,EAAE;AALuB,CAA7B","sourcesContent":["export const PREFERENCES_DEFAULTS = {\n\tfeatures: {\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t},\n\teditorMode: 'visual',\n};\n"]}
@@ -32,6 +32,17 @@ export const preferences = combineReducers({
32
32
  default:
33
33
  return state;
34
34
  }
35
+ },
36
+
37
+ editorMode() {
38
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS.editorMode;
39
+ let action = arguments.length > 1 ? arguments[1] : undefined;
40
+
41
+ if (action.type === 'SWITCH_MODE') {
42
+ return action.mode;
43
+ }
44
+
45
+ return state;
35
46
  }
36
47
 
37
48
  });