@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
@@ -36,7 +36,7 @@ import {
36
36
  export const setupEditor =
37
37
  ( post, edits, template ) =>
38
38
  ( { dispatch } ) => {
39
- dispatch.setupEditorState( post );
39
+ dispatch.setEditedPost( post.type, post.id );
40
40
  // Apply a template for new posts only, if exists.
41
41
  const isNewPost = post.status === 'auto-draft';
42
42
  if ( isNewPost && template ) {
@@ -70,10 +70,18 @@ export const setupEditor =
70
70
  * Returns an action object signalling that the editor is being destroyed and
71
71
  * that any necessary state or side-effect cleanup should occur.
72
72
  *
73
+ * @deprecated
74
+ *
73
75
  * @return {Object} Action object.
74
76
  */
75
77
  export function __experimentalTearDownEditor() {
76
- return { type: 'TEAR_DOWN_EDITOR' };
78
+ deprecated(
79
+ "wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor",
80
+ {
81
+ since: '6.5',
82
+ }
83
+ );
84
+ return { type: 'DO_NOTHING' };
77
85
  }
78
86
 
79
87
  /**
@@ -109,17 +117,33 @@ export function updatePost() {
109
117
  }
110
118
 
111
119
  /**
112
- * Returns an action object used to setup the editor state when first opening
113
- * an editor.
120
+ * Setup the editor state.
121
+ *
122
+ * @deprecated
114
123
  *
115
124
  * @param {Object} post Post object.
125
+ */
126
+ export function setupEditorState( post ) {
127
+ deprecated( "wp.data.dispatch( 'core/editor' ).setupEditorState", {
128
+ since: '6.5',
129
+ alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost",
130
+ } );
131
+ return setEditedPost( post.type, post.id );
132
+ }
133
+
134
+ /**
135
+ * Returns an action that sets the current post Type and post ID.
136
+ *
137
+ * @param {string} postType Post Type.
138
+ * @param {string} postId Post ID.
116
139
  *
117
140
  * @return {Object} Action object.
118
141
  */
119
- export function setupEditorState( post ) {
142
+ export function setEditedPost( postType, postId ) {
120
143
  return {
121
- type: 'SETUP_EDITOR_STATE',
122
- post,
144
+ type: 'SET_EDITED_POST',
145
+ postType,
146
+ postId,
123
147
  };
124
148
  }
125
149
 
@@ -560,8 +584,12 @@ export function updateEditorSettings( settings ) {
560
584
  */
561
585
  export const setRenderingMode =
562
586
  ( mode ) =>
563
- ( { dispatch, registry } ) => {
564
- registry.dispatch( blockEditorStore ).clearSelectedBlock();
587
+ ( { dispatch, registry, select } ) => {
588
+ if ( select.__unstableIsEditorReady() ) {
589
+ // We clear the block selection but we also need to clear the selection from the core store.
590
+ registry.dispatch( blockEditorStore ).clearSelectedBlock();
591
+ dispatch.editPost( { selection: undefined }, { undoIgnore: true } );
592
+ }
565
593
 
566
594
  dispatch( {
567
595
  type: 'SET_RENDERING_MODE',
@@ -569,6 +597,129 @@ export const setRenderingMode =
569
597
  } );
570
598
  };
571
599
 
600
+ /**
601
+ * Action that changes the width of the editing canvas.
602
+ *
603
+ * @param {string} deviceType
604
+ *
605
+ * @return {Object} Action object.
606
+ */
607
+ export function setDeviceType( deviceType ) {
608
+ return {
609
+ type: 'SET_DEVICE_TYPE',
610
+ deviceType,
611
+ };
612
+ }
613
+
614
+ /**
615
+ * Returns an action object used to enable or disable a panel in the editor.
616
+ *
617
+ * @param {string} panelName A string that identifies the panel to enable or disable.
618
+ *
619
+ * @return {Object} Action object.
620
+ */
621
+ export const toggleEditorPanelEnabled =
622
+ ( panelName ) =>
623
+ ( { registry } ) => {
624
+ const inactivePanels =
625
+ registry
626
+ .select( preferencesStore )
627
+ .get( 'core', 'inactivePanels' ) ?? [];
628
+
629
+ const isPanelInactive = !! inactivePanels?.includes( panelName );
630
+
631
+ // If the panel is inactive, remove it to enable it, else add it to
632
+ // make it inactive.
633
+ let updatedInactivePanels;
634
+ if ( isPanelInactive ) {
635
+ updatedInactivePanels = inactivePanels.filter(
636
+ ( invactivePanelName ) => invactivePanelName !== panelName
637
+ );
638
+ } else {
639
+ updatedInactivePanels = [ ...inactivePanels, panelName ];
640
+ }
641
+
642
+ registry
643
+ .dispatch( preferencesStore )
644
+ .set( 'core', 'inactivePanels', updatedInactivePanels );
645
+ };
646
+
647
+ /**
648
+ * Opens a closed panel and closes an open panel.
649
+ *
650
+ * @param {string} panelName A string that identifies the panel to open or close.
651
+ */
652
+ export const toggleEditorPanelOpened =
653
+ ( panelName ) =>
654
+ ( { registry } ) => {
655
+ const openPanels =
656
+ registry.select( preferencesStore ).get( 'core', 'openPanels' ) ??
657
+ [];
658
+
659
+ const isPanelOpen = !! openPanels?.includes( panelName );
660
+
661
+ // If the panel is open, remove it to close it, else add it to
662
+ // make it open.
663
+ let updatedOpenPanels;
664
+ if ( isPanelOpen ) {
665
+ updatedOpenPanels = openPanels.filter(
666
+ ( openPanelName ) => openPanelName !== panelName
667
+ );
668
+ } else {
669
+ updatedOpenPanels = [ ...openPanels, panelName ];
670
+ }
671
+
672
+ registry
673
+ .dispatch( preferencesStore )
674
+ .set( 'core', 'openPanels', updatedOpenPanels );
675
+ };
676
+
677
+ /**
678
+ * Returns an action object used to remove a panel from the editor.
679
+ *
680
+ * @param {string} panelName A string that identifies the panel to remove.
681
+ *
682
+ * @return {Object} Action object.
683
+ */
684
+ export function removeEditorPanel( panelName ) {
685
+ return {
686
+ type: 'REMOVE_PANEL',
687
+ panelName,
688
+ };
689
+ }
690
+
691
+ /**
692
+ * Returns an action object used to open/close the inserter.
693
+ *
694
+ * @param {boolean|Object} value Whether the inserter should be
695
+ * opened (true) or closed (false).
696
+ * To specify an insertion point,
697
+ * use an object.
698
+ * @param {string} value.rootClientId The root client ID to insert at.
699
+ * @param {number} value.insertionIndex The index to insert at.
700
+ *
701
+ * @return {Object} Action object.
702
+ */
703
+ export function setIsInserterOpened( value ) {
704
+ return {
705
+ type: 'SET_IS_INSERTER_OPENED',
706
+ value,
707
+ };
708
+ }
709
+
710
+ /**
711
+ * Returns an action object used to open/close the list view.
712
+ *
713
+ * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
714
+ * @return {Object} Action object.
715
+ */
716
+ export function setIsListViewOpened( isOpen ) {
717
+ return {
718
+ type: 'SET_IS_LIST_VIEW_OPENED',
719
+ isOpen,
720
+ };
721
+ }
722
+
572
723
  /**
573
724
  * Backward compatibility
574
725
  */
@@ -27,4 +27,5 @@ export const EDITOR_SETTINGS_DEFAULTS = {
27
27
  richEditingEnabled: true,
28
28
  codeEditingEnabled: true,
29
29
  enableCustomFields: undefined,
30
+ defaultRenderingMode: 'post-only',
30
31
  };
@@ -9,7 +9,10 @@ import { createReduxStore, register } from '@wordpress/data';
9
9
  import reducer from './reducer';
10
10
  import * as selectors from './selectors';
11
11
  import * as actions from './actions';
12
+ import * as privateActions from './private-actions';
13
+ import * as privateSelectors from './private-selectors';
12
14
  import { STORE_NAME } from './constants';
15
+ import { unlock } from '../lock-unlock';
13
16
 
14
17
  /**
15
18
  * Post editor data store configuration.
@@ -36,3 +39,5 @@ export const store = createReduxStore( STORE_NAME, {
36
39
  } );
37
40
 
38
41
  register( store );
42
+ unlock( store ).registerPrivateActions( privateActions );
43
+ unlock( store ).registerPrivateSelectors( privateSelectors );
@@ -0,0 +1,61 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as coreStore } from '@wordpress/core-data';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+
8
+ /**
9
+ * Returns an action object used to set which template is currently being used/edited.
10
+ *
11
+ * @param {string} id Template Id.
12
+ *
13
+ * @return {Object} Action object.
14
+ */
15
+ export function setCurrentTemplateId( id ) {
16
+ return {
17
+ type: 'SET_CURRENT_TEMPLATE_ID',
18
+ id,
19
+ };
20
+ }
21
+
22
+ /**
23
+ * Create a block based template.
24
+ *
25
+ * @param {Object?} template Template to create and assign.
26
+ */
27
+ export const createTemplate =
28
+ ( template ) =>
29
+ async ( { select, dispatch, registry } ) => {
30
+ const savedTemplate = await registry
31
+ .dispatch( coreStore )
32
+ .saveEntityRecord( 'postType', 'wp_template', template );
33
+ registry
34
+ .dispatch( coreStore )
35
+ .editEntityRecord(
36
+ 'postType',
37
+ select.getCurrentPostType(),
38
+ select.getCurrentPostId(),
39
+ {
40
+ template: savedTemplate.slug,
41
+ }
42
+ );
43
+ registry
44
+ .dispatch( noticesStore )
45
+ .createSuccessNotice(
46
+ __( "Custom template created. You're in template mode now." ),
47
+ {
48
+ type: 'snackbar',
49
+ actions: [
50
+ {
51
+ label: __( 'Go back' ),
52
+ onClick: () =>
53
+ dispatch.setRenderingMode(
54
+ select.getEditorSettings()
55
+ .defaultRenderingMode
56
+ ),
57
+ },
58
+ ],
59
+ }
60
+ );
61
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as blockEditorStore } from '@wordpress/block-editor';
5
+ import { createRegistrySelector } from '@wordpress/data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { getRenderingMode } from './selectors';
11
+
12
+ const EMPTY_INSERTION_POINT = {
13
+ rootClientId: undefined,
14
+ insertionIndex: undefined,
15
+ filterValue: undefined,
16
+ };
17
+
18
+ /**
19
+ * Get the insertion point for the inserter.
20
+ *
21
+ * @param {Object} state Global application state.
22
+ *
23
+ * @return {Object} The root client ID, index to insert at and starting filter value.
24
+ */
25
+ export const getInsertionPoint = createRegistrySelector(
26
+ ( select ) => ( state ) => {
27
+ if ( typeof state.blockInserterPanel === 'object' ) {
28
+ return state.blockInserterPanel;
29
+ }
30
+
31
+ if ( getRenderingMode( state ) === 'template-locked' ) {
32
+ const [ postContentClientId ] =
33
+ select( blockEditorStore ).__experimentalGetGlobalBlocksByName(
34
+ 'core/post-content'
35
+ );
36
+ if ( postContentClientId ) {
37
+ return {
38
+ rootClientId: postContentClientId,
39
+ insertionIndex: undefined,
40
+ filterValue: undefined,
41
+ };
42
+ }
43
+ }
44
+
45
+ return EMPTY_INSERTION_POINT;
46
+ }
47
+ );
48
+
49
+ export function getListViewToggleRef( state ) {
50
+ return state.listViewToggleRef;
51
+ }
@@ -83,8 +83,17 @@ export function shouldOverwriteState( action, previousAction ) {
83
83
 
84
84
  export function postId( state = null, action ) {
85
85
  switch ( action.type ) {
86
- case 'SETUP_EDITOR_STATE':
87
- return action.post.id;
86
+ case 'SET_EDITED_POST':
87
+ return action.postId;
88
+ }
89
+
90
+ return state;
91
+ }
92
+
93
+ export function templateId( state = null, action ) {
94
+ switch ( action.type ) {
95
+ case 'SET_CURRENT_TEMPLATE_ID':
96
+ return action.id;
88
97
  }
89
98
 
90
99
  return state;
@@ -92,8 +101,8 @@ export function postId( state = null, action ) {
92
101
 
93
102
  export function postType( state = null, action ) {
94
103
  switch ( action.type ) {
95
- case 'SETUP_EDITOR_STATE':
96
- return action.post.type;
104
+ case 'SET_EDITED_POST':
105
+ return action.postType;
97
106
  }
98
107
 
99
108
  return state;
@@ -238,66 +247,134 @@ export function postAutosavingLock( state = {}, action ) {
238
247
  }
239
248
 
240
249
  /**
241
- * Reducer returning whether the editor is ready to be rendered.
242
- * The editor is considered ready to be rendered once
243
- * the post object is loaded properly and the initial blocks parsed.
250
+ * Reducer returning the post editor setting.
244
251
  *
245
- * @param {boolean} state
246
- * @param {Object} action
252
+ * @param {Object} state Current state.
253
+ * @param {Object} action Dispatched action.
247
254
  *
248
- * @return {boolean} Updated state.
255
+ * @return {Object} Updated state.
249
256
  */
250
- export function isReady( state = false, action ) {
257
+ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
251
258
  switch ( action.type ) {
252
- case 'SETUP_EDITOR_STATE':
253
- return true;
259
+ case 'UPDATE_EDITOR_SETTINGS':
260
+ return {
261
+ ...state,
262
+ ...action.settings,
263
+ };
264
+ }
254
265
 
255
- case 'TEAR_DOWN_EDITOR':
256
- return false;
266
+ return state;
267
+ }
268
+
269
+ export function renderingMode( state = 'all', action ) {
270
+ switch ( action.type ) {
271
+ case 'SET_RENDERING_MODE':
272
+ return action.mode;
257
273
  }
258
274
 
259
275
  return state;
260
276
  }
261
277
 
262
278
  /**
263
- * Reducer returning the post editor setting.
279
+ * Reducer returning the editing canvas device type.
264
280
  *
265
281
  * @param {Object} state Current state.
266
282
  * @param {Object} action Dispatched action.
267
283
  *
268
284
  * @return {Object} Updated state.
269
285
  */
270
- export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
286
+ export function deviceType( state = 'Desktop', action ) {
271
287
  switch ( action.type ) {
272
- case 'UPDATE_EDITOR_SETTINGS':
273
- return {
274
- ...state,
275
- ...action.settings,
276
- };
288
+ case 'SET_DEVICE_TYPE':
289
+ return action.deviceType;
277
290
  }
278
291
 
279
292
  return state;
280
293
  }
281
294
 
282
- export function renderingMode( state = 'all', action ) {
295
+ /**
296
+ * Reducer storing the list of all programmatically removed panels.
297
+ *
298
+ * @param {Array} state Current state.
299
+ * @param {Object} action Action object.
300
+ *
301
+ * @return {Array} Updated state.
302
+ */
303
+ export function removedPanels( state = [], action ) {
283
304
  switch ( action.type ) {
284
- case 'SET_RENDERING_MODE':
285
- return action.mode;
305
+ case 'REMOVE_PANEL':
306
+ if ( ! state.includes( action.panelName ) ) {
307
+ return [ ...state, action.panelName ];
308
+ }
286
309
  }
287
310
 
288
311
  return state;
289
312
  }
290
313
 
314
+ /**
315
+ * Reducer to set the block inserter panel open or closed.
316
+ *
317
+ * Note: this reducer interacts with the list view panel reducer
318
+ * to make sure that only one of the two panels is open at the same time.
319
+ *
320
+ * @param {Object} state Current state.
321
+ * @param {Object} action Dispatched action.
322
+ */
323
+ export function blockInserterPanel( state = false, action ) {
324
+ switch ( action.type ) {
325
+ case 'SET_IS_LIST_VIEW_OPENED':
326
+ return action.isOpen ? false : state;
327
+ case 'SET_IS_INSERTER_OPENED':
328
+ return action.value;
329
+ }
330
+ return state;
331
+ }
332
+
333
+ /**
334
+ * Reducer to set the list view panel open or closed.
335
+ *
336
+ * Note: this reducer interacts with the inserter panel reducer
337
+ * to make sure that only one of the two panels is open at the same time.
338
+ *
339
+ * @param {Object} state Current state.
340
+ * @param {Object} action Dispatched action.
341
+ */
342
+ export function listViewPanel( state = false, action ) {
343
+ switch ( action.type ) {
344
+ case 'SET_IS_INSERTER_OPENED':
345
+ return action.value ? false : state;
346
+ case 'SET_IS_LIST_VIEW_OPENED':
347
+ return action.isOpen;
348
+ }
349
+ return state;
350
+ }
351
+
352
+ /**
353
+ * This reducer does nothing aside initializing a ref to the list view toggle.
354
+ * We will have a unique ref per "editor" instance.
355
+ *
356
+ * @param {Object} state
357
+ * @return {Object} Reference to the list view toggle button.
358
+ */
359
+ export function listViewToggleRef( state = { current: null } ) {
360
+ return state;
361
+ }
362
+
291
363
  export default combineReducers( {
292
364
  postId,
293
365
  postType,
366
+ templateId,
294
367
  saving,
295
368
  deleting,
296
369
  postLock,
297
370
  template,
298
371
  postSavingLock,
299
- isReady,
300
372
  editorSettings,
301
373
  postAutosavingLock,
302
374
  renderingMode,
375
+ deviceType,
376
+ removedPanels,
377
+ blockInserterPanel,
378
+ listViewPanel,
379
+ listViewToggleRef,
303
380
  } );
@@ -13,7 +13,6 @@ import {
13
13
  postLock,
14
14
  postSavingLock,
15
15
  template,
16
- isReady,
17
16
  editorSettings,
18
17
  } from './reducer.js';
19
18
 
@@ -87,7 +86,6 @@ export default combineReducers( {
87
86
  postLock,
88
87
  postSavingLock,
89
88
  template,
90
- isReady,
91
89
  editorSettings,
92
90
  clipboard,
93
91
  notices,