@wordpress/editor 13.24.1 → 13.26.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 (307) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/document-bar/index.js +164 -0
  4. package/build/components/document-bar/index.js.map +1 -0
  5. package/build/components/document-outline/index.js +82 -1
  6. package/build/components/document-outline/index.js.map +1 -1
  7. package/build/components/document-tools/index.js +160 -0
  8. package/build/components/document-tools/index.js.map +1 -0
  9. package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
  10. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  11. package/build/components/editor-canvas/index.js +298 -0
  12. package/build/components/editor-canvas/index.js.map +1 -0
  13. package/build/components/entities-saved-states/index.js +3 -1
  14. package/build/components/entities-saved-states/index.js.map +1 -1
  15. package/build/components/global-keyboard-shortcuts/index.js +12 -2
  16. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  17. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
  18. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  19. package/build/components/index.js +72 -8
  20. package/build/components/index.js.map +1 -1
  21. package/build/components/index.native.js +9 -1
  22. package/build/components/index.native.js.map +1 -1
  23. package/build/components/inserter-sidebar/index.js +77 -0
  24. package/build/components/inserter-sidebar/index.js.map +1 -0
  25. package/build/components/list-view-sidebar/index.js +150 -0
  26. package/build/components/list-view-sidebar/index.js.map +1 -0
  27. package/build/components/list-view-sidebar/list-view-outline.js +28 -0
  28. package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
  29. package/build/components/offline-status/index.native.js +85 -0
  30. package/build/components/offline-status/index.native.js.map +1 -0
  31. package/build/components/page-attributes/panel.js +63 -0
  32. package/build/components/page-attributes/panel.js.map +1 -0
  33. package/build/components/post-discussion/panel.js +59 -0
  34. package/build/components/post-discussion/panel.js.map +1 -0
  35. package/build/components/post-excerpt/check.js +19 -0
  36. package/build/components/post-excerpt/check.js.map +1 -1
  37. package/build/components/post-excerpt/panel.js +55 -0
  38. package/build/components/post-excerpt/panel.js.map +1 -0
  39. package/build/components/post-excerpt/plugin.js +72 -0
  40. package/build/components/post-excerpt/plugin.js.map +1 -0
  41. package/build/components/post-featured-image/index.js +5 -8
  42. package/build/components/post-featured-image/index.js.map +1 -1
  43. package/build/components/post-featured-image/panel.js +60 -0
  44. package/build/components/post-featured-image/panel.js.map +1 -0
  45. package/build/components/post-last-revision/panel.js +27 -0
  46. package/build/components/post-last-revision/panel.js.map +1 -0
  47. package/build/components/post-publish-button/index.js +1 -0
  48. package/build/components/post-publish-button/index.js.map +1 -1
  49. package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
  50. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  51. package/build/components/post-saved-state/index.js +13 -8
  52. package/build/components/post-saved-state/index.js.map +1 -1
  53. package/build/components/post-schedule/panel.js +1 -1
  54. package/build/components/post-schedule/panel.js.map +1 -1
  55. package/build/components/post-taxonomies/panel.js +68 -0
  56. package/build/components/post-taxonomies/panel.js.map +1 -0
  57. package/build/components/post-template/block-theme.js +100 -0
  58. package/build/components/post-template/block-theme.js.map +1 -0
  59. package/build/components/post-template/classic-theme.js +171 -0
  60. package/build/components/post-template/classic-theme.js.map +1 -0
  61. package/build/components/post-template/create-new-template-modal.js +98 -0
  62. package/build/components/post-template/create-new-template-modal.js.map +1 -0
  63. package/build/components/post-template/create-new-template.js +55 -0
  64. package/build/components/post-template/create-new-template.js.map +1 -0
  65. package/build/components/post-template/hooks.js +88 -0
  66. package/build/components/post-template/hooks.js.map +1 -0
  67. package/build/components/post-template/panel.js +70 -0
  68. package/build/components/post-template/panel.js.map +1 -0
  69. package/build/components/post-template/reset-default-template.js +48 -0
  70. package/build/components/post-template/reset-default-template.js.map +1 -0
  71. package/build/components/post-template/swap-template-button.js +86 -0
  72. package/build/components/post-template/swap-template-button.js.map +1 -0
  73. package/build/components/post-title/index.native.js +25 -15
  74. package/build/components/post-title/index.native.js.map +1 -1
  75. package/build/components/post-view-link/index.js +58 -0
  76. package/build/components/post-view-link/index.js.map +1 -0
  77. package/build/components/post-visibility/check.js +5 -17
  78. package/build/components/post-visibility/check.js.map +1 -1
  79. package/build/components/preview-dropdown/index.js +118 -0
  80. package/build/components/preview-dropdown/index.js.map +1 -0
  81. package/build/components/provider/index.js +24 -82
  82. package/build/components/provider/index.js.map +1 -1
  83. package/build/components/provider/index.native.js +36 -8
  84. package/build/components/provider/index.native.js.map +1 -1
  85. package/build/components/provider/navigation-block-editing-mode.js +40 -0
  86. package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
  87. package/build/components/provider/use-block-editor-settings.js +38 -15
  88. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  89. package/build/hooks/index.js +1 -0
  90. package/build/hooks/index.js.map +1 -1
  91. package/build/hooks/pattern-partial-syncing.js +49 -0
  92. package/build/hooks/pattern-partial-syncing.js.map +1 -0
  93. package/build/private-apis.js +14 -0
  94. package/build/private-apis.js.map +1 -1
  95. package/build/store/actions.js +161 -13
  96. package/build/store/actions.js.map +1 -1
  97. package/build/store/defaults.js +2 -1
  98. package/build/store/defaults.js.map +1 -1
  99. package/build/store/index.js +5 -0
  100. package/build/store/index.js.map +1 -1
  101. package/build/store/private-actions.js +52 -0
  102. package/build/store/private-actions.js.map +1 -0
  103. package/build/store/private-selectors.js +52 -0
  104. package/build/store/private-selectors.js.map +1 -0
  105. package/build/store/reducer.js +109 -27
  106. package/build/store/reducer.js.map +1 -1
  107. package/build/store/reducer.native.js +0 -1
  108. package/build/store/reducer.native.js.map +1 -1
  109. package/build/store/selectors.js +104 -9
  110. package/build/store/selectors.js.map +1 -1
  111. package/build/utils/media-upload/index.js +8 -2
  112. package/build/utils/media-upload/index.js.map +1 -1
  113. package/build-module/components/document-bar/index.js +156 -0
  114. package/build-module/components/document-bar/index.js.map +1 -0
  115. package/build-module/components/document-outline/index.js +82 -1
  116. package/build-module/components/document-outline/index.js.map +1 -1
  117. package/build-module/components/document-tools/index.js +151 -0
  118. package/build-module/components/document-tools/index.js.map +1 -0
  119. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
  120. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  121. package/build-module/components/editor-canvas/index.js +289 -0
  122. package/build-module/components/editor-canvas/index.js.map +1 -0
  123. package/build-module/components/entities-saved-states/index.js +3 -1
  124. package/build-module/components/entities-saved-states/index.js.map +1 -1
  125. package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
  126. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  127. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
  128. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  129. package/build-module/components/index.js +9 -1
  130. package/build-module/components/index.js.map +1 -1
  131. package/build-module/components/index.native.js +1 -0
  132. package/build-module/components/index.native.js.map +1 -1
  133. package/build-module/components/inserter-sidebar/index.js +70 -0
  134. package/build-module/components/inserter-sidebar/index.js.map +1 -0
  135. package/build-module/components/list-view-sidebar/index.js +142 -0
  136. package/build-module/components/list-view-sidebar/index.js.map +1 -0
  137. package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
  138. package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
  139. package/build-module/components/offline-status/index.native.js +77 -0
  140. package/build-module/components/offline-status/index.native.js.map +1 -0
  141. package/build-module/components/page-attributes/panel.js +53 -0
  142. package/build-module/components/page-attributes/panel.js.map +1 -0
  143. package/build-module/components/post-discussion/panel.js +50 -0
  144. package/build-module/components/post-discussion/panel.js.map +1 -0
  145. package/build-module/components/post-excerpt/check.js +19 -0
  146. package/build-module/components/post-excerpt/check.js.map +1 -1
  147. package/build-module/components/post-excerpt/panel.js +48 -0
  148. package/build-module/components/post-excerpt/panel.js.map +1 -0
  149. package/build-module/components/post-excerpt/plugin.js +64 -0
  150. package/build-module/components/post-excerpt/plugin.js.map +1 -0
  151. package/build-module/components/post-featured-image/index.js +5 -8
  152. package/build-module/components/post-featured-image/index.js.map +1 -1
  153. package/build-module/components/post-featured-image/panel.js +51 -0
  154. package/build-module/components/post-featured-image/panel.js.map +1 -0
  155. package/build-module/components/post-last-revision/panel.js +18 -0
  156. package/build-module/components/post-last-revision/panel.js.map +1 -0
  157. package/build-module/components/post-publish-button/index.js +1 -0
  158. package/build-module/components/post-publish-button/index.js.map +1 -1
  159. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
  160. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  161. package/build-module/components/post-saved-state/index.js +13 -8
  162. package/build-module/components/post-saved-state/index.js.map +1 -1
  163. package/build-module/components/post-schedule/panel.js +1 -1
  164. package/build-module/components/post-schedule/panel.js.map +1 -1
  165. package/build-module/components/post-taxonomies/panel.js +59 -0
  166. package/build-module/components/post-taxonomies/panel.js.map +1 -0
  167. package/build-module/components/post-template/block-theme.js +92 -0
  168. package/build-module/components/post-template/block-theme.js.map +1 -0
  169. package/build-module/components/post-template/classic-theme.js +162 -0
  170. package/build-module/components/post-template/classic-theme.js.map +1 -0
  171. package/build-module/components/post-template/create-new-template-modal.js +91 -0
  172. package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
  173. package/build-module/components/post-template/create-new-template.js +47 -0
  174. package/build-module/components/post-template/create-new-template.js.map +1 -0
  175. package/build-module/components/post-template/hooks.js +78 -0
  176. package/build-module/components/post-template/hooks.js.map +1 -0
  177. package/build-module/components/post-template/panel.js +62 -0
  178. package/build-module/components/post-template/panel.js.map +1 -0
  179. package/build-module/components/post-template/reset-default-template.js +41 -0
  180. package/build-module/components/post-template/reset-default-template.js.map +1 -0
  181. package/build-module/components/post-template/swap-template-button.js +79 -0
  182. package/build-module/components/post-template/swap-template-button.js.map +1 -0
  183. package/build-module/components/post-title/index.native.js +26 -16
  184. package/build-module/components/post-title/index.native.js.map +1 -1
  185. package/build-module/components/post-view-link/index.js +51 -0
  186. package/build-module/components/post-view-link/index.js.map +1 -0
  187. package/build-module/components/post-visibility/check.js +6 -16
  188. package/build-module/components/post-visibility/check.js.map +1 -1
  189. package/build-module/components/preview-dropdown/index.js +110 -0
  190. package/build-module/components/preview-dropdown/index.js.map +1 -0
  191. package/build-module/components/provider/index.js +25 -83
  192. package/build-module/components/provider/index.js.map +1 -1
  193. package/build-module/components/provider/index.native.js +37 -9
  194. package/build-module/components/provider/index.native.js.map +1 -1
  195. package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
  196. package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
  197. package/build-module/components/provider/use-block-editor-settings.js +38 -15
  198. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  199. package/build-module/hooks/index.js +1 -0
  200. package/build-module/hooks/index.js.map +1 -1
  201. package/build-module/hooks/pattern-partial-syncing.js +46 -0
  202. package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
  203. package/build-module/private-apis.js +14 -0
  204. package/build-module/private-apis.js.map +1 -1
  205. package/build-module/store/actions.js +147 -9
  206. package/build-module/store/actions.js.map +1 -1
  207. package/build-module/store/defaults.js +2 -1
  208. package/build-module/store/defaults.js.map +1 -1
  209. package/build-module/store/index.js +5 -0
  210. package/build-module/store/index.js.map +1 -1
  211. package/build-module/store/private-actions.js +44 -0
  212. package/build-module/store/private-actions.js.map +1 -0
  213. package/build-module/store/private-selectors.js +43 -0
  214. package/build-module/store/private-selectors.js.map +1 -0
  215. package/build-module/store/reducer.js +103 -26
  216. package/build-module/store/reducer.js.map +1 -1
  217. package/build-module/store/reducer.native.js +1 -2
  218. package/build-module/store/reducer.native.js.map +1 -1
  219. package/build-module/store/selectors.js +93 -6
  220. package/build-module/store/selectors.js.map +1 -1
  221. package/build-module/utils/media-upload/index.js +8 -2
  222. package/build-module/utils/media-upload/index.js.map +1 -1
  223. package/build-style/style-rtl.css +433 -0
  224. package/build-style/style.css +433 -0
  225. package/package.json +32 -31
  226. package/src/components/document-bar/index.js +193 -0
  227. package/src/components/document-bar/style.scss +130 -0
  228. package/src/components/document-outline/index.js +48 -1
  229. package/src/components/document-outline/style.scss +12 -0
  230. package/src/components/document-tools/index.js +177 -0
  231. package/src/components/document-tools/style.scss +98 -0
  232. package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
  233. package/src/components/editor-canvas/index.js +386 -0
  234. package/src/components/editor-canvas/style.scss +5 -0
  235. package/src/components/entities-saved-states/index.js +3 -1
  236. package/src/components/entities-saved-states/style.scss +4 -0
  237. package/src/components/global-keyboard-shortcuts/index.js +12 -2
  238. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
  239. package/src/components/index.js +9 -1
  240. package/src/components/index.native.js +1 -0
  241. package/src/components/inserter-sidebar/index.js +73 -0
  242. package/src/components/inserter-sidebar/style.scss +22 -0
  243. package/src/components/list-view-sidebar/index.js +169 -0
  244. package/src/components/list-view-sidebar/list-view-outline.js +37 -0
  245. package/src/components/list-view-sidebar/style.scss +84 -0
  246. package/src/components/offline-status/index.native.js +101 -0
  247. package/src/components/offline-status/style.native.scss +28 -0
  248. package/src/components/offline-status/test/index.native.js +108 -0
  249. package/src/components/page-attributes/panel.js +62 -0
  250. package/src/components/post-discussion/panel.js +57 -0
  251. package/src/components/post-excerpt/check.js +18 -0
  252. package/src/components/post-excerpt/panel.js +57 -0
  253. package/src/components/post-excerpt/plugin.js +61 -0
  254. package/src/components/post-excerpt/test/plugin.js +36 -0
  255. package/src/components/post-featured-image/index.js +3 -7
  256. package/src/components/post-featured-image/panel.js +55 -0
  257. package/src/components/post-last-revision/panel.js +22 -0
  258. package/src/components/post-last-revision/style.scss +10 -0
  259. package/src/components/post-publish-button/index.js +1 -0
  260. package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
  261. package/src/components/post-saved-state/index.js +9 -8
  262. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
  263. package/src/components/post-schedule/panel.js +1 -1
  264. package/src/components/post-taxonomies/panel.js +66 -0
  265. package/src/components/post-template/block-theme.js +110 -0
  266. package/src/components/post-template/classic-theme.js +213 -0
  267. package/src/components/post-template/create-new-template-modal.js +139 -0
  268. package/src/components/post-template/create-new-template.js +50 -0
  269. package/src/components/post-template/hooks.js +95 -0
  270. package/src/components/post-template/panel.js +66 -0
  271. package/src/components/post-template/reset-default-template.js +43 -0
  272. package/src/components/post-template/style.scss +52 -0
  273. package/src/components/post-template/swap-template-button.js +86 -0
  274. package/src/components/post-title/index.native.js +32 -18
  275. package/src/components/post-title/style.scss +1 -0
  276. package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
  277. package/src/components/post-title/test/index.native.js +78 -0
  278. package/src/components/post-view-link/index.js +47 -0
  279. package/src/components/post-visibility/check.js +10 -15
  280. package/src/components/post-visibility/test/check.js +24 -13
  281. package/src/components/preview-dropdown/index.js +133 -0
  282. package/src/components/preview-dropdown/style.scss +5 -0
  283. package/src/components/provider/index.js +28 -118
  284. package/src/components/provider/index.native.js +55 -14
  285. package/src/components/provider/navigation-block-editing-mode.js +37 -0
  286. package/src/components/provider/use-block-editor-settings.js +42 -17
  287. package/src/hooks/index.js +1 -0
  288. package/src/hooks/pattern-partial-syncing.js +73 -0
  289. package/src/private-apis.js +14 -0
  290. package/src/store/actions.js +160 -9
  291. package/src/store/defaults.js +1 -0
  292. package/src/store/index.js +5 -0
  293. package/src/store/private-actions.js +61 -0
  294. package/src/store/private-selectors.js +51 -0
  295. package/src/store/reducer.js +103 -26
  296. package/src/store/reducer.native.js +0 -2
  297. package/src/store/selectors.js +144 -42
  298. package/src/store/test/actions.js +56 -0
  299. package/src/store/test/reducer.js +98 -0
  300. package/src/store/test/selectors.js +137 -147
  301. package/src/style.scss +7 -0
  302. package/src/utils/media-upload/index.js +9 -2
  303. package/build/components/post-template/index.js +0 -66
  304. package/build/components/post-template/index.js.map +0 -1
  305. package/build-module/components/post-template/index.js +0 -57
  306. package/build-module/components/post-template/index.js.map +0 -1
  307. package/src/components/post-template/index.js +0 -64
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = EditTemplateBlocksNotification;
7
+ var _react = require("react");
8
+ var _data = require("@wordpress/data");
9
+ var _element = require("@wordpress/element");
10
+ var _notices = require("@wordpress/notices");
11
+ var _i18n = require("@wordpress/i18n");
12
+ var _components = require("@wordpress/components");
13
+ var _store = require("../../store");
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+
22
+ /**
23
+ * Component that:
24
+ *
25
+ * - Displays a 'Edit your template to edit this block' notification when the
26
+ * user is focusing on editing page content and clicks on a disabled template
27
+ * block.
28
+ * - Displays a 'Edit your template to edit this block' dialog when the user
29
+ * is focusing on editing page conetnt and double clicks on a disabled
30
+ * template block.
31
+ *
32
+ * @param {Object} props
33
+ * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
34
+ * editor iframe canvas.
35
+ */
36
+ function EditTemplateBlocksNotification({
37
+ contentRef
38
+ }) {
39
+ const renderingMode = (0, _data.useSelect)(select => select(_store.store).getRenderingMode(), []);
40
+ const {
41
+ getNotices
42
+ } = (0, _data.useSelect)(_notices.store);
43
+ const {
44
+ createInfoNotice,
45
+ removeNotice
46
+ } = (0, _data.useDispatch)(_notices.store);
47
+ const {
48
+ setRenderingMode
49
+ } = (0, _data.useDispatch)(_store.store);
50
+ const [isDialogOpen, setIsDialogOpen] = (0, _element.useState)(false);
51
+ const lastNoticeId = (0, _element.useRef)(0);
52
+ (0, _element.useEffect)(() => {
53
+ const handleClick = async event => {
54
+ if (renderingMode !== 'template-locked') {
55
+ return;
56
+ }
57
+ if (!event.target.classList.contains('is-root-container')) {
58
+ return;
59
+ }
60
+ const isNoticeAlreadyShowing = getNotices().some(notice => notice.id === lastNoticeId.current);
61
+ if (isNoticeAlreadyShowing) {
62
+ return;
63
+ }
64
+ const {
65
+ notice
66
+ } = await createInfoNotice((0, _i18n.__)('Edit your template to edit this block.'), {
67
+ isDismissible: true,
68
+ type: 'snackbar',
69
+ actions: [{
70
+ label: (0, _i18n.__)('Edit template'),
71
+ onClick: () => setRenderingMode('template-only')
72
+ }]
73
+ });
74
+ lastNoticeId.current = notice.id;
75
+ };
76
+ const handleDblClick = event => {
77
+ if (renderingMode !== 'template-locked') {
78
+ return;
79
+ }
80
+ if (!event.target.classList.contains('is-root-container')) {
81
+ return;
82
+ }
83
+ if (lastNoticeId.current) {
84
+ removeNotice(lastNoticeId.current);
85
+ }
86
+ setIsDialogOpen(true);
87
+ };
88
+ const canvas = contentRef.current;
89
+ canvas?.addEventListener('click', handleClick);
90
+ canvas?.addEventListener('dblclick', handleDblClick);
91
+ return () => {
92
+ canvas?.removeEventListener('click', handleClick);
93
+ canvas?.removeEventListener('dblclick', handleDblClick);
94
+ };
95
+ }, [lastNoticeId, renderingMode, contentRef.current]);
96
+ return (0, _react.createElement)(_components.__experimentalConfirmDialog, {
97
+ isOpen: isDialogOpen,
98
+ confirmButtonText: (0, _i18n.__)('Edit template'),
99
+ onConfirm: () => {
100
+ setIsDialogOpen(false);
101
+ setRenderingMode('template-only');
102
+ },
103
+ onCancel: () => setIsDialogOpen(false)
104
+ }, (0, _i18n.__)('Edit your template to edit this block.'));
105
+ }
106
+ //# sourceMappingURL=edit-template-blocks-notification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_element","_notices","_i18n","_components","_store","EditTemplateBlocksNotification","contentRef","renderingMode","useSelect","select","editorStore","getRenderingMode","getNotices","noticesStore","createInfoNotice","removeNotice","useDispatch","setRenderingMode","isDialogOpen","setIsDialogOpen","useState","lastNoticeId","useRef","useEffect","handleClick","event","target","classList","contains","isNoticeAlreadyShowing","some","notice","id","current","__","isDismissible","type","actions","label","onClick","handleDblClick","canvas","addEventListener","removeEventListener","_react","createElement","__experimentalConfirmDialog","isOpen","confirmButtonText","onConfirm","onCancel"],"sources":["@wordpress/editor/src/components/editor-canvas/edit-template-blocks-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useState, useRef } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page conetnt and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst renderingMode = useSelect(\n\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t[]\n\t);\n\tconst { getNotices } = useSelect( noticesStore );\n\n\tconst { createInfoNotice, removeNotice } = useDispatch( noticesStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tconst lastNoticeId = useRef( 0 );\n\n\tuseEffect( () => {\n\t\tconst handleClick = async ( event ) => {\n\t\t\tif ( renderingMode !== 'template-locked' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst isNoticeAlreadyShowing = getNotices().some(\n\t\t\t\t( notice ) => notice.id === lastNoticeId.current\n\t\t\t);\n\t\t\tif ( isNoticeAlreadyShowing ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst { notice } = await createInfoNotice(\n\t\t\t\t__( 'Edit your template to edit this block.' ),\n\t\t\t\t{\n\t\t\t\t\tisDismissible: true,\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: __( 'Edit template' ),\n\t\t\t\t\t\t\tonClick: () => setRenderingMode( 'template-only' ),\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\tlastNoticeId.current = notice.id;\n\t\t};\n\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( renderingMode !== 'template-locked' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( ! event.target.classList.contains( 'is-root-container' ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( lastNoticeId.current ) {\n\t\t\t\tremoveNotice( lastNoticeId.current );\n\t\t\t}\n\t\t\tsetIsDialogOpen( true );\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'click', handleClick );\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'click', handleClick );\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ lastNoticeId, renderingMode, contentRef.current ] );\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tsetRenderingMode( 'template-only' );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t>\n\t\t\t{ __( 'Edit your template to edit this block.' ) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AAC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EAAE,wCAAyC,CACjC,CAAC;AAElB"}
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = require("react");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _blockEditor = require("@wordpress/block-editor");
11
+ var _element = require("@wordpress/element");
12
+ var _data = require("@wordpress/data");
13
+ var _blocks = require("@wordpress/blocks");
14
+ var _coreData = require("@wordpress/core-data");
15
+ var _compose = require("@wordpress/compose");
16
+ var _postTitle = _interopRequireDefault(require("../post-title"));
17
+ var _store = require("../../store");
18
+ var _lockUnlock = require("../../lock-unlock");
19
+ var _editTemplateBlocksNotification = _interopRequireDefault(require("./edit-template-blocks-notification"));
20
+ /**
21
+ * External dependencies
22
+ */
23
+
24
+ /**
25
+ * WordPress dependencies
26
+ */
27
+
28
+ /**
29
+ * Internal dependencies
30
+ */
31
+
32
+ const {
33
+ LayoutStyle,
34
+ useLayoutClasses,
35
+ useLayoutStyles,
36
+ ExperimentalBlockCanvas: BlockCanvas
37
+ } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
38
+ const noop = () => {};
39
+
40
+ /**
41
+ * Given an array of nested blocks, find the first Post Content
42
+ * block inside it, recursing through any nesting levels,
43
+ * and return its attributes.
44
+ *
45
+ * @param {Array} blocks A list of blocks.
46
+ *
47
+ * @return {Object | undefined} The Post Content block.
48
+ */
49
+ function getPostContentAttributes(blocks) {
50
+ for (let i = 0; i < blocks.length; i++) {
51
+ if (blocks[i].name === 'core/post-content') {
52
+ return blocks[i].attributes;
53
+ }
54
+ if (blocks[i].innerBlocks.length) {
55
+ const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
56
+ if (nestedPostContent) {
57
+ return nestedPostContent;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ function checkForPostContentAtRootLevel(blocks) {
63
+ for (let i = 0; i < blocks.length; i++) {
64
+ if (blocks[i].name === 'core/post-content') {
65
+ return true;
66
+ }
67
+ }
68
+ return false;
69
+ }
70
+ function EditorCanvas({
71
+ // Ideally as we unify post and site editors, we won't need these props.
72
+ autoFocus,
73
+ className,
74
+ renderAppender,
75
+ styles,
76
+ disableIframe = false,
77
+ iframeProps,
78
+ children
79
+ }) {
80
+ const {
81
+ renderingMode,
82
+ postContentAttributes,
83
+ editedPostTemplate = {},
84
+ wrapperBlockName,
85
+ wrapperUniqueId,
86
+ deviceType,
87
+ hasHistory
88
+ } = (0, _data.useSelect)(select => {
89
+ const {
90
+ getCurrentPostId,
91
+ getCurrentPostType,
92
+ getCurrentTemplateId,
93
+ getEditorSettings,
94
+ getRenderingMode,
95
+ getDeviceType
96
+ } = select(_store.store);
97
+ const {
98
+ getPostType,
99
+ canUser,
100
+ getEditedEntityRecord
101
+ } = select(_coreData.store);
102
+ const postTypeSlug = getCurrentPostType();
103
+ const _renderingMode = getRenderingMode();
104
+ let _wrapperBlockName;
105
+ if (postTypeSlug === 'wp_block') {
106
+ _wrapperBlockName = 'core/block';
107
+ } else if (!_renderingMode === 'post-only') {
108
+ _wrapperBlockName = 'core/post-content';
109
+ }
110
+ const editorSettings = getEditorSettings();
111
+ const supportsTemplateMode = editorSettings.supportsTemplateMode;
112
+ const postType = getPostType(postTypeSlug);
113
+ const canEditTemplate = canUser('create', 'templates');
114
+ const currentTemplateId = getCurrentTemplateId();
115
+ const template = currentTemplateId ? getEditedEntityRecord('postType', 'wp_template', currentTemplateId) : undefined;
116
+ return {
117
+ renderingMode: _renderingMode,
118
+ postContentAttributes: editorSettings.postContentAttributes,
119
+ // Post template fetch returns a 404 on classic themes, which
120
+ // messes with e2e tests, so check it's a block theme first.
121
+ editedPostTemplate: postType?.viewable && supportsTemplateMode && canEditTemplate ? template : undefined,
122
+ wrapperBlockName: _wrapperBlockName,
123
+ wrapperUniqueId: getCurrentPostId(),
124
+ deviceType: getDeviceType(),
125
+ hasHistory: !!editorSettings.goBack
126
+ };
127
+ }, []);
128
+ const {
129
+ isCleanNewPost
130
+ } = (0, _data.useSelect)(_store.store);
131
+ const {
132
+ hasRootPaddingAwareAlignments,
133
+ themeHasDisabledLayoutStyles,
134
+ themeSupportsLayout
135
+ } = (0, _data.useSelect)(select => {
136
+ const _settings = select(_blockEditor.store).getSettings();
137
+ return {
138
+ themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
139
+ themeSupportsLayout: _settings.supportsLayout,
140
+ hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments
141
+ };
142
+ }, []);
143
+ const deviceStyles = (0, _blockEditor.__experimentalUseResizeCanvas)(deviceType);
144
+ const [globalLayoutSettings] = (0, _blockEditor.useSettings)('layout');
145
+
146
+ // fallbackLayout is used if there is no Post Content,
147
+ // and for Post Title.
148
+ const fallbackLayout = (0, _element.useMemo)(() => {
149
+ if (renderingMode !== 'post-only') {
150
+ return {
151
+ type: 'default'
152
+ };
153
+ }
154
+ if (themeSupportsLayout) {
155
+ // We need to ensure support for wide and full alignments,
156
+ // so we add the constrained type.
157
+ return {
158
+ ...globalLayoutSettings,
159
+ type: 'constrained'
160
+ };
161
+ }
162
+ // Set default layout for classic themes so all alignments are supported.
163
+ return {
164
+ type: 'default'
165
+ };
166
+ }, [renderingMode, themeSupportsLayout, globalLayoutSettings]);
167
+ const newestPostContentAttributes = (0, _element.useMemo)(() => {
168
+ if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
169
+ return postContentAttributes;
170
+ }
171
+ // When in template editing mode, we can access the blocks directly.
172
+ if (editedPostTemplate?.blocks) {
173
+ return getPostContentAttributes(editedPostTemplate?.blocks);
174
+ }
175
+ // If there are no blocks, we have to parse the content string.
176
+ // Best double-check it's a string otherwise the parse function gets unhappy.
177
+ const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
178
+ return getPostContentAttributes((0, _blocks.parse)(parseableContent)) || {};
179
+ }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
180
+ const hasPostContentAtRootLevel = (0, _element.useMemo)(() => {
181
+ if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
182
+ return false;
183
+ }
184
+ // When in template editing mode, we can access the blocks directly.
185
+ if (editedPostTemplate?.blocks) {
186
+ return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
187
+ }
188
+ // If there are no blocks, we have to parse the content string.
189
+ // Best double-check it's a string otherwise the parse function gets unhappy.
190
+ const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
191
+ return checkForPostContentAtRootLevel((0, _blocks.parse)(parseableContent)) || false;
192
+ }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
193
+ const {
194
+ layout = {},
195
+ align = ''
196
+ } = newestPostContentAttributes || {};
197
+ const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
198
+ const blockListLayoutClass = (0, _classnames.default)({
199
+ 'is-layout-flow': !themeSupportsLayout
200
+ }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
201
+ const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
202
+
203
+ // Update type for blocks using legacy layouts.
204
+ const postContentLayout = (0, _element.useMemo)(() => {
205
+ return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
206
+ ...globalLayoutSettings,
207
+ ...layout,
208
+ type: 'constrained'
209
+ } : {
210
+ ...globalLayoutSettings,
211
+ ...layout,
212
+ type: 'default'
213
+ };
214
+ }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
215
+
216
+ // If there is a Post Content block we use its layout for the block list;
217
+ // if not, this must be a classic theme, in which case we use the fallback layout.
218
+ const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
219
+ const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
220
+ const observeTypingRef = (0, _blockEditor.__unstableUseTypingObserver)();
221
+ const titleRef = (0, _element.useRef)();
222
+ (0, _element.useEffect)(() => {
223
+ if (!autoFocus || !isCleanNewPost()) {
224
+ return;
225
+ }
226
+ titleRef?.current?.focus();
227
+ }, [autoFocus, isCleanNewPost]);
228
+
229
+ // Add some styles for alignwide/alignfull Post Content and its children.
230
+ const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
231
+ .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
232
+ .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
233
+ .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
234
+ const localRef = (0, _element.useRef)();
235
+ const typewriterRef = (0, _blockEditor.__unstableUseTypewriter)();
236
+ const contentRef = (0, _compose.useMergeRefs)([localRef, renderingMode === 'post-only' ? typewriterRef : noop]);
237
+ return (0, _react.createElement)(BlockCanvas, {
238
+ shouldIframe: !disableIframe || ['Tablet', 'Mobile'].includes(deviceType),
239
+ contentRef: contentRef,
240
+ styles: styles,
241
+ height: "100%",
242
+ iframeProps: {
243
+ className: (0, _classnames.default)('editor-canvas__iframe', {
244
+ 'has-history': hasHistory
245
+ }),
246
+ ...iframeProps,
247
+ style: {
248
+ ...iframeProps?.style,
249
+ ...deviceStyles
250
+ }
251
+ }
252
+ }, themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(LayoutStyle, {
253
+ selector: ".editor-editor-canvas__post-title-wrapper",
254
+ layout: fallbackLayout
255
+ }), (0, _react.createElement)(LayoutStyle, {
256
+ selector: ".block-editor-block-list__layout.is-root-container",
257
+ layout: postEditorLayout
258
+ }), align && (0, _react.createElement)(LayoutStyle, {
259
+ css: alignCSS
260
+ }), postContentLayoutStyles && (0, _react.createElement)(LayoutStyle, {
261
+ layout: postContentLayout,
262
+ css: postContentLayoutStyles
263
+ })), renderingMode === 'post-only' && (0, _react.createElement)("div", {
264
+ className: (0, _classnames.default)('editor-editor-canvas__post-title-wrapper',
265
+ // The following class is only here for backward comapatibility
266
+ // some themes might be using it to style the post title.
267
+ 'edit-post-visual-editor__post-title-wrapper', {
268
+ 'has-global-padding': hasRootPaddingAwareAlignments
269
+ }),
270
+ contentEditable: false,
271
+ ref: observeTypingRef,
272
+ style: {
273
+ // This is using inline styles
274
+ // so it's applied for both iframed and non iframed editors.
275
+ marginTop: '4rem'
276
+ }
277
+ }, (0, _react.createElement)(_postTitle.default, {
278
+ ref: titleRef
279
+ })), (0, _react.createElement)(_blockEditor.__experimentalRecursionProvider, {
280
+ blockName: wrapperBlockName,
281
+ uniqueId: wrapperUniqueId
282
+ }, (0, _react.createElement)(_blockEditor.BlockList, {
283
+ className: (0, _classnames.default)(className, 'is-' + deviceType.toLowerCase() + '-preview', renderingMode !== 'post-only' ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
284
+ ),
285
+
286
+ layout: blockListLayout,
287
+ dropZoneElement:
288
+ // When iframed, pass in the html element of the iframe to
289
+ // ensure the drop zone extends to the edges of the iframe.
290
+ disableIframe ? localRef.current : localRef.current?.parentNode,
291
+ renderAppender: renderAppender
292
+ }), (0, _react.createElement)(_editTemplateBlocksNotification.default, {
293
+ contentRef: localRef
294
+ })), children);
295
+ }
296
+ var _default = EditorCanvas;
297
+ exports.default = _default;
298
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_element","_data","_blocks","_coreData","_compose","_postTitle","_store","_lockUnlock","_editTemplateBlocksNotification","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","unlock","blockEditorPrivateApis","noop","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","EditorCanvas","autoFocus","className","renderAppender","styles","disableIframe","iframeProps","children","renderingMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","deviceType","hasHistory","useSelect","select","getCurrentPostId","getCurrentPostType","getCurrentTemplateId","getEditorSettings","getRenderingMode","getDeviceType","editorStore","getPostType","canUser","getEditedEntityRecord","coreStore","postTypeSlug","_renderingMode","_wrapperBlockName","editorSettings","supportsTemplateMode","postType","canEditTemplate","currentTemplateId","template","undefined","viewable","goBack","isCleanNewPost","hasRootPaddingAwareAlignments","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","blockEditorStore","getSettings","disableLayoutStyles","supportsLayout","__experimentalFeatures","useRootPaddingAwareAlignments","deviceStyles","useResizeCanvas","globalLayoutSettings","useSettings","fallbackLayout","useMemo","type","newestPostContentAttributes","content","parseableContent","parse","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","classnames","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","useTypingObserver","titleRef","useRef","useEffect","current","focus","alignCSS","localRef","typewriterRef","useTypewriter","contentRef","useMergeRefs","_react","createElement","shouldIframe","includes","height","style","Fragment","selector","css","contentEditable","ref","marginTop","default","__experimentalRecursionProvider","blockName","uniqueId","BlockList","toLowerCase","dropZoneElement","parentNode","_default","exports"],"sources":["@wordpress/editor/src/components/editor-canvas/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\tuseSettings,\n\t__experimentalRecursionProvider as RecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostTitle from '../post-title';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport EditTemplateBlocksNotification from './edit-template-blocks-notification';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n} = unlock( blockEditorPrivateApis );\n\nconst noop = () => {};\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction EditorCanvas( {\n\t// Ideally as we unify post and site editors, we won't need these props.\n\tautoFocus,\n\tclassName,\n\trenderAppender,\n\tstyles,\n\tdisableIframe = false,\n\tiframeProps,\n\tchildren,\n} ) {\n\tconst {\n\t\trenderingMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tdeviceType,\n\t\thasHistory,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostId,\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentTemplateId,\n\t\t\tgetEditorSettings,\n\t\t\tgetRenderingMode,\n\t\t\tgetDeviceType,\n\t\t} = select( editorStore );\n\t\tconst { getPostType, canUser, getEditedEntityRecord } =\n\t\t\tselect( coreStore );\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tconst _renderingMode = getRenderingMode();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _renderingMode === 'post-only' ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postType = getPostType( postTypeSlug );\n\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\tconst currentTemplateId = getCurrentTemplateId();\n\t\tconst template = currentTemplateId\n\t\t\t? getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tcurrentTemplateId\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\trenderingMode: _renderingMode,\n\t\t\tpostContentAttributes: editorSettings.postContentAttributes,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostType?.viewable && supportsTemplateMode && canEditTemplate\n\t\t\t\t\t? template\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tdeviceType: getDeviceType(),\n\t\t\thasHistory: !! editorSettings.goBack,\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\n\tconst deviceStyles = useResizeCanvas( deviceType );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( renderingMode !== 'post-only' ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ renderingMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif (\n\t\t\t! editedPostTemplate?.content &&\n\t\t\t! editedPostTemplate?.blocks &&\n\t\t\tpostContentAttributes\n\t\t) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( ! autoFocus || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ autoFocus, isCleanNewPost ] );\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst localRef = useRef();\n\tconst typewriterRef = useTypewriter();\n\tconst contentRef = useMergeRefs( [\n\t\tlocalRef,\n\t\trenderingMode === 'post-only' ? typewriterRef : noop,\n\t] );\n\n\treturn (\n\t\t<BlockCanvas\n\t\t\tshouldIframe={\n\t\t\t\t! disableIframe || [ 'Tablet', 'Mobile' ].includes( deviceType )\n\t\t\t}\n\t\t\tcontentRef={ contentRef }\n\t\t\tstyles={ styles }\n\t\t\theight=\"100%\"\n\t\t\tiframeProps={ {\n\t\t\t\tclassName: classnames( 'editor-canvas__iframe', {\n\t\t\t\t\t'has-history': hasHistory,\n\t\t\t\t} ),\n\t\t\t\t...iframeProps,\n\t\t\t\tstyle: {\n\t\t\t\t\t...iframeProps?.style,\n\t\t\t\t\t...deviceStyles,\n\t\t\t\t},\n\t\t\t} }\n\t\t>\n\t\t\t{ themeSupportsLayout &&\n\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\trenderingMode === 'post-only' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".editor-editor-canvas__post-title-wrapper\"\n\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ align && <LayoutStyle css={ alignCSS } /> }\n\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t{ renderingMode === 'post-only' && (\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'editor-editor-canvas__post-title-wrapper',\n\t\t\t\t\t\t// The following class is only here for backward comapatibility\n\t\t\t\t\t\t// some themes might be using it to style the post title.\n\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'has-global-padding': hasRootPaddingAwareAlignments,\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t// This is using inline styles\n\t\t\t\t\t\t// so it's applied for both iframed and non iframed editors.\n\t\t\t\t\t\tmarginTop: '4rem',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<RecursionProvider\n\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t>\n\t\t\t\t<BlockList\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t'is-' + deviceType.toLowerCase() + '-preview',\n\t\t\t\t\t\trenderingMode !== 'post-only'\n\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t) }\n\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\tdisableIframe\n\t\t\t\t\t\t\t? localRef.current\n\t\t\t\t\t\t\t: localRef.current?.parentNode\n\t\t\t\t\t}\n\t\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t/>\n\t\t\t\t<EditTemplateBlocksNotification contentRef={ localRef } />\n\t\t\t</RecursionProvider>\n\t\t\t{ children }\n\t\t</BlockCanvas>\n\t);\n}\n\nexport default EditorCanvas;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,UAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,+BAAA,GAAAX,sBAAA,CAAAC,OAAA;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;;AAMA,MAAM;EACLW,WAAW;EACXC,gBAAgB;EAChBC,eAAe;EACfC,uB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AAA6G,OAAA,CAAAT,OAAA,GAAAQ,QAAA"}
@@ -179,7 +179,9 @@ function EntitiesSavedStatesExtensible({
179
179
  onClick: dismissPanel
180
180
  }, (0, _i18n.__)('Cancel'))), (0, _react.createElement)("div", {
181
181
  className: "entities-saved-states__text-prompt"
182
- }, (0, _react.createElement)("strong", null, (0, _i18n.__)('Are you ready to save?')), additionalPrompt, isDirty && (0, _react.createElement)("p", null, (0, _i18n.__)('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
182
+ }, (0, _react.createElement)("strong", {
183
+ className: "entities-saved-states__text-prompt--header"
184
+ }, (0, _i18n.__)('Are you ready to save?')), additionalPrompt, isDirty && (0, _react.createElement)("p", null, (0, _i18n.__)('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
183
185
  return (0, _react.createElement)(_entityTypeList.default, {
184
186
  key: list[0].name,
185
187
  list: list,
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_i18n","_data","_element","_coreData","_blockEditor","_compose","_notices","_entityTypeList","_interopRequireDefault","_useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","useIsDirty","_react","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","__","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","useRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","useDispatch","coreStore","__unstableMarkLastChangeAsPersistent","blockEditorStore","createSuccessNotice","createErrorNotice","removeNotice","noticesStore","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","useSelect","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","useCallback","saveDialogRef","saveDialogProps","useDialog","onClose","ref","className","Flex","gap","FlexItem","isBlock","as","Button","variant","disabled","onClick","map","list","default"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong>{ __( 'Are you ready to save?' ) }</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t{ isDirty && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAA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AC9D,IAAAnF,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAAyG,QAAQ;IACRC,OAAO;IACPC,EAAE,EAAGC,kBAAQ;IACbP,GAAG,EAAGlE,aAAe;IACrB0E,OAAO,EAAC,SAAS;IACjBC,QAAQ,EAAG,CAAEnF,WAAa;IAC1BoF,OAAO,EAAGxC,mBAAqB;IAC/B+B,SAAS,EAAC;EAA2C,GAEnDzE,SACO,CAAC,EACX,IAAAR,MAAA,CAAAC,aAAA,EAACtB,WAAA,CAAAyG,QAAQ;IACRC,OAAO;IACPC,EAAE,EAAGC,kBAAQ;IACbC,OAAO,EAAC,WAAW;IACnBE,OAAO,EAAGhB;EAAc,GAEtB,IAAAjE,QAAE,EAAE,QAAS,CACN,CACL,CAAC,EAEP,IAAAT,MAAA,CAAAC,aAAA;IAAKgF,SAAS,EAAC;EAAoC,GAClD,IAAAjF,MAAA,CAAAC,aAAA,kBAAU,IAAAQ,QAAE,EAAE,wBAAyB,CAAW,CAAC,EACjDN,gBAAgB,EAChBQ,OAAO,IACR,IAAAX,MAAA,CAAAC,aAAA,aACG,IAAAQ,QAAE,EACH,4EACD,CACE,CAEA,CAAC,EAEJ+B,yBAAyB,CAACmD,GAAG,CAAIC,IAAI,IAAM;IAC5C,OACC,IAAA5F,MAAA,CAAAC,aAAA,EAACb,eAAA,CAAAyG,OAAc;MACdxC,GAAG,EAAGuC,IAAI,CAAE,CAAC,CAAE,CAACnG,IAAM;MACtBmG,IAAI,EAAGA,IAAM;MACb/E,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
1
+ {"version":3,"names":["_components","require","_i18n","_data","_element","_coreData","_blockEditor","_compose","_notices","_entityTypeList","_interopRequireDefault","_useIsDirty","PUBLISH_ON_SAVE_ENTITIES","kind","name","identity","values","EntitiesSavedStates","close","isDirtyProps","useIsDirty","_react","createElement","EntitiesSavedStatesExtensible","additionalPrompt","undefined","onSave","saveEnabled","saveEnabledProp","saveLabel","__","dirtyEntityRecords","isDirty","setUnselectedEntities","unselectedEntities","saveButtonRef","useRef","editEntityRecord","saveEditedEntityRecord","__experimentalSaveSpecifiedEntityEdits","saveSpecifiedEntityEdits","useDispatch","coreStore","__unstableMarkLastChangeAsPersistent","blockEditorStore","createSuccessNotice","createErrorNotice","removeNotice","noticesStore","partitionedSavables","reduce","acc","record","push","site","siteSavables","wp_template","templateSavables","wp_template_part","templatePartSavables","contentSavables","sortedPartitionedSavables","Object","filter","Array","isArray","homeUrl","useSelect","select","getUnstableBase","home","saveCheckedEntities","saveNoticeId","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","typeToPublish","status","length","Promise","all","then","value","type","id","actions","label","url","catch","error","dismissPanel","useCallback","saveDialogRef","saveDialogProps","useDialog","onClose","ref","className","Flex","gap","FlexItem","isBlock","as","Button","variant","disabled","onClick","map","list","default"],"sources":["@wordpress/editor/src/components/entities-saved-states/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, Flex, FlexItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { __experimentalUseDialog as useDialog } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport EntityTypeList from './entity-type-list';\nimport { useIsDirty } from './hooks/use-is-dirty';\n\nconst PUBLISH_ON_SAVE_ENTITIES = [\n\t{\n\t\tkind: 'postType',\n\t\tname: 'wp_navigation',\n\t},\n];\n\nfunction identity( values ) {\n\treturn values;\n}\n\nexport default function EntitiesSavedStates( { close } ) {\n\tconst isDirtyProps = useIsDirty();\n\treturn (\n\t\t<EntitiesSavedStatesExtensible close={ close } { ...isDirtyProps } />\n\t);\n}\n\nexport function EntitiesSavedStatesExtensible( {\n\tadditionalPrompt = undefined,\n\tclose,\n\tonSave = identity,\n\tsaveEnabled: saveEnabledProp = undefined,\n\tsaveLabel = __( 'Save' ),\n\n\tdirtyEntityRecords,\n\tisDirty,\n\tsetUnselectedEntities,\n\tunselectedEntities,\n} ) {\n\tconst saveButtonRef = useRef();\n\tconst {\n\t\teditEntityRecord,\n\t\tsaveEditedEntityRecord,\n\t\t__experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits,\n\t} = useDispatch( coreStore );\n\n\tconst { __unstableMarkLastChangeAsPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { createSuccessNotice, createErrorNotice, removeNotice } =\n\t\tuseDispatch( noticesStore );\n\n\t// To group entities by type.\n\tconst partitionedSavables = dirtyEntityRecords.reduce( ( acc, record ) => {\n\t\tconst { name } = record;\n\t\tif ( ! acc[ name ] ) {\n\t\t\tacc[ name ] = [];\n\t\t}\n\t\tacc[ name ].push( record );\n\t\treturn acc;\n\t}, {} );\n\n\t// Sort entity groups.\n\tconst {\n\t\tsite: siteSavables,\n\t\twp_template: templateSavables,\n\t\twp_template_part: templatePartSavables,\n\t\t...contentSavables\n\t} = partitionedSavables;\n\tconst sortedPartitionedSavables = [\n\t\tsiteSavables,\n\t\ttemplateSavables,\n\t\ttemplatePartSavables,\n\t\t...Object.values( contentSavables ),\n\t].filter( Array.isArray );\n\n\tconst saveEnabled = saveEnabledProp ?? isDirty;\n\n\tconst { homeUrl } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t};\n\t}, [] );\n\n\tconst saveCheckedEntities = () => {\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tremoveNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! unselectedEntities.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\n\t\tclose( entitiesToSave );\n\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\teditEntityRecord( kind, name, key, { status: 'publish' } );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tsaveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tsaveSpecifiedEntityEdits(\n\t\t\t\t\t'root',\n\t\t\t\t\t'site',\n\t\t\t\t\tundefined,\n\t\t\t\t\tsiteItemsToSave\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\t__unstableMarkLastChangeAsPersistent();\n\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave( values );\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tcreateErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tcreateSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tcreateErrorNotice( `${ __( 'Saving failed.' ) } ${ error }` )\n\t\t\t);\n\t};\n\n\t// Explicitly define this with no argument passed. Using `close` on\n\t// its own will use the event object in place of the expected saved entities.\n\tconst dismissPanel = useCallback( () => close(), [ close ] );\n\n\tconst [ saveDialogRef, saveDialogProps ] = useDialog( {\n\t\tonClose: () => dismissPanel(),\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ saveDialogRef }\n\t\t\t{ ...saveDialogProps }\n\t\t\tclassName=\"entities-saved-states__panel\"\n\t\t>\n\t\t\t<Flex className=\"entities-saved-states__panel-header\" gap={ 2 }>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tref={ saveButtonRef }\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tdisabled={ ! saveEnabled }\n\t\t\t\t\tonClick={ saveCheckedEntities }\n\t\t\t\t\tclassName=\"editor-entities-saved-states__save-button\"\n\t\t\t\t>\n\t\t\t\t\t{ saveLabel }\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem\n\t\t\t\t\tisBlock\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ dismissPanel }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\n\t\t\t<div className=\"entities-saved-states__text-prompt\">\n\t\t\t\t<strong className=\"entities-saved-states__text-prompt--header\">\n\t\t\t\t\t{ __( 'Are you ready to save?' ) }\n\t\t\t\t</strong>\n\t\t\t\t{ additionalPrompt }\n\t\t\t\t{ isDirty && (\n\t\t\t\t\t<p>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'The following changes have been made to your site, templates, and content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t</div>\n\n\t\t\t{ sortedPartitionedSavables.map( ( list ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<EntityTypeList\n\t\t\t\t\t\tkey={ list[ 0 ].name }\n\t\t\t\t\t\tlist={ list }\n\t\t\t\t\t\tunselectedEntities={ unselectedEntities }\n\t\t\t\t\t\tsetUnselectedEntities={ setUnselectedEntities }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,eAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA,MAAMW,wBAAwB,GAAG,CAChC;EACCC,IAAI,EAAE,UAAU;EAChBC,IAAI,EAAE;AACP,CAAC,CACD;AAED,SAASC,QAAQA,CAAEC,MAAM,EAAG;EAC3B,OAAOA,MAAM;AACd;AAEe,SAASC,mBAAmBA,CAAE;EAAEC;AAAM,CAAC,EAAG;EACxD,MAAMC,YAAY,GAAG,IAAAC,sBAAU,EAAC,CAAC;EACjC,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACC,6BAA6B;IAACL,KAAK,EAAGA,KAAO;IAAA,GAAMC;EAAY,CAAI,CAAC;AAE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ACD,CACE,CAEA,CAAC,EAEJ+B,yBAAyB,CAACmD,GAAG,CAAIC,IAAI,IAAM;IAC5C,OACC,IAAA5F,MAAA,CAAAC,aAAA,EAACb,eAAA,CAAAyG,OAAc;MACdxC,GAAG,EAAGuC,IAAI,CAAE,CAAC,CAAE,CAACnG,IAAM;MACtBmG,IAAI,EAAGA,IAAM;MACb/E,kBAAkB,EAAGA,kBAAoB;MACzCD,qBAAqB,EAAGA;IAAuB,CAC/C,CAAC;EAEJ,CAAE,CACE,CAAC;AAER"}
@@ -19,11 +19,13 @@ function EditorKeyboardShortcuts() {
19
19
  const {
20
20
  redo,
21
21
  undo,
22
- savePost
22
+ savePost,
23
+ setIsListViewOpened
23
24
  } = (0, _data.useDispatch)(_store.store);
24
25
  const {
25
26
  isEditedPostDirty,
26
- isPostSavingLocked
27
+ isPostSavingLocked,
28
+ isListViewOpened
27
29
  } = (0, _data.useSelect)(_store.store);
28
30
  (0, _keyboardShortcuts.useShortcut)('core/editor/undo', event => {
29
31
  undo();
@@ -53,6 +55,14 @@ function EditorKeyboardShortcuts() {
53
55
  }
54
56
  savePost();
55
57
  });
58
+
59
+ // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
60
+ (0, _keyboardShortcuts.useShortcut)('core/editor/toggle-list-view', event => {
61
+ if (!isListViewOpened()) {
62
+ event.preventDefault();
63
+ setIsListViewOpened(true);
64
+ }
65
+ });
56
66
  return null;
57
67
  }
58
68
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_keyboardShortcuts","require","_data","_store","EditorKeyboardShortcuts","redo","undo","savePost","useDispatch","editorStore","isEditedPostDirty","isPostSavingLocked","useSelect","useShortcut","event","preventDefault"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function EditorKeyboardShortcuts() {\n\tconst { redo, undo, savePost } = useDispatch( editorStore );\n\tconst { isEditedPostDirty, isPostSavingLocked } = useSelect( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAG,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC3D,MAAM;IAAEC,iBAAiB;IAAEC;EAAmB,CAAC,GAAG,IAAAC,eAAS,EAAEH,YAAY,CAAC;EAE1E,IAAAI,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CR,IAAI,CAAC,CAAC;IACNQ,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CT,IAAI,CAAC,CAAC;IACNS,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CA,KAAK,CAACC,cAAc,CAAC,CAAC;;IAEtB;AACF;AACA;IACE,IAAKJ,kBAAkB,CAAC,CAAC,EAAG;MAC3B;IACD;;IAEA;IACA;IACA;IACA;IACA;IACA,IAAK,CAAED,iBAAiB,CAAC,CAAC,EAAG;MAC5B;IACD;IAEAH,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ"}
1
+ {"version":3,"names":["_keyboardShortcuts","require","_data","_store","EditorKeyboardShortcuts","redo","undo","savePost","setIsListViewOpened","useDispatch","editorStore","isEditedPostDirty","isPostSavingLocked","isListViewOpened","useSelect","useShortcut","event","preventDefault"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function EditorKeyboardShortcuts() {\n\tconst { redo, undo, savePost, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst { isEditedPostDirty, isPostSavingLocked, isListViewOpened } =\n\t\tuseSelect( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\t// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.\n\tuseShortcut( 'core/editor/toggle-list-view', ( event ) => {\n\t\tif ( ! isListViewOpened() ) {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsListViewOpened( true );\n\t\t}\n\t} );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAoB,CAAC,GAClD,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC3B,MAAM;IAAEC,iBAAiB;IAAEC,kBAAkB;IAAEC;EAAiB,CAAC,GAChE,IAAAC,eAAS,EAAEJ,YAAY,CAAC;EAEzB,IAAAK,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CV,IAAI,CAAC,CAAC;IACNU,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CX,IAAI,CAAC,CAAC;IACNW,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CA,KAAK,CAACC,cAAc,CAAC,CAAC;;IAEtB;AACF;AACA;IACE,IAAKL,kBAAkB,CAAC,CAAC,EAAG;MAC3B;IACD;;IAEA;IACA;IACA;IACA;IACA;IACA,IAAK,CAAED,iBAAiB,CAAC,CAAC,EAAG;MAC5B;IACD;IAEAJ,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;;EAEH;EACA,IAAAQ,8BAAW,EAAE,8BAA8B,EAAIC,KAAK,IAAM;IACzD,IAAK,CAAEH,gBAAgB,CAAC,CAAC,EAAG;MAC3BG,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBT,mBAAmB,CAAE,IAAK,CAAC;IAC5B;EACD,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ"}
@@ -56,6 +56,15 @@ function EditorKeyboardShortcutsRegister() {
56
56
  character: 'y'
57
57
  }]
58
58
  });
59
+ registerShortcut({
60
+ name: 'core/editor/toggle-list-view',
61
+ category: 'global',
62
+ description: (0, _i18n.__)('Open the block list view.'),
63
+ keyCombination: {
64
+ modifier: 'access',
65
+ character: 'o'
66
+ }
67
+ });
59
68
  }, [registerShortcut]);
60
69
  return (0, _react.createElement)(_blockEditor.BlockEditorKeyboardShortcuts.Register, null);
61
70
  }