@wordpress/editor 13.24.0 → 13.25.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 (175) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/document-bar/index.js +152 -0
  3. package/build/components/document-bar/index.js.map +1 -0
  4. package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
  5. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  6. package/build/components/editor-canvas/index.js +292 -0
  7. package/build/components/editor-canvas/index.js.map +1 -0
  8. package/build/components/index.js +24 -8
  9. package/build/components/index.js.map +1 -1
  10. package/build/components/post-publish-button/index.js +1 -0
  11. package/build/components/post-publish-button/index.js.map +1 -1
  12. package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
  13. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  14. package/build/components/post-saved-state/index.js +1 -0
  15. package/build/components/post-saved-state/index.js.map +1 -1
  16. package/build/components/post-schedule/panel.js +1 -1
  17. package/build/components/post-schedule/panel.js.map +1 -1
  18. package/build/components/post-template/block-theme.js +99 -0
  19. package/build/components/post-template/block-theme.js.map +1 -0
  20. package/build/components/post-template/classic-theme.js +171 -0
  21. package/build/components/post-template/classic-theme.js.map +1 -0
  22. package/build/components/post-template/create-new-template-modal.js +98 -0
  23. package/build/components/post-template/create-new-template-modal.js.map +1 -0
  24. package/build/components/post-template/create-new-template.js +55 -0
  25. package/build/components/post-template/create-new-template.js.map +1 -0
  26. package/build/components/post-template/hooks.js +88 -0
  27. package/build/components/post-template/hooks.js.map +1 -0
  28. package/build/components/post-template/panel.js +71 -0
  29. package/build/components/post-template/panel.js.map +1 -0
  30. package/build/components/post-template/reset-default-template.js +48 -0
  31. package/build/components/post-template/reset-default-template.js.map +1 -0
  32. package/build/components/post-template/swap-template-button.js +84 -0
  33. package/build/components/post-template/swap-template-button.js.map +1 -0
  34. package/build/components/post-title/index.native.js +0 -1
  35. package/build/components/post-title/index.native.js.map +1 -1
  36. package/build/components/preview-dropdown/index.js +113 -0
  37. package/build/components/preview-dropdown/index.js.map +1 -0
  38. package/build/components/provider/index.js +36 -77
  39. package/build/components/provider/index.js.map +1 -1
  40. package/build/components/provider/index.native.js +17 -8
  41. package/build/components/provider/index.native.js.map +1 -1
  42. package/build/components/provider/navigation-block-editing-mode.js +40 -0
  43. package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
  44. package/build/components/provider/use-block-editor-settings.js +9 -10
  45. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  46. package/build/hooks/index.js +1 -0
  47. package/build/hooks/index.js.map +1 -1
  48. package/build/hooks/pattern-partial-syncing.js +49 -0
  49. package/build/hooks/pattern-partial-syncing.js.map +1 -0
  50. package/build/private-apis.js +4 -0
  51. package/build/private-apis.js.map +1 -1
  52. package/build/store/actions.js +59 -11
  53. package/build/store/actions.js.map +1 -1
  54. package/build/store/defaults.js +2 -1
  55. package/build/store/defaults.js.map +1 -1
  56. package/build/store/index.js +3 -0
  57. package/build/store/index.js.map +1 -1
  58. package/build/store/private-actions.js +52 -0
  59. package/build/store/private-actions.js.map +1 -0
  60. package/build/store/reducer.js +32 -27
  61. package/build/store/reducer.js.map +1 -1
  62. package/build/store/reducer.native.js +0 -1
  63. package/build/store/reducer.native.js.map +1 -1
  64. package/build/store/selectors.js +31 -10
  65. package/build/store/selectors.js.map +1 -1
  66. package/build-module/components/document-bar/index.js +144 -0
  67. package/build-module/components/document-bar/index.js.map +1 -0
  68. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
  69. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
  70. package/build-module/components/editor-canvas/index.js +283 -0
  71. package/build-module/components/editor-canvas/index.js.map +1 -0
  72. package/build-module/components/index.js +3 -1
  73. package/build-module/components/index.js.map +1 -1
  74. package/build-module/components/post-publish-button/index.js +1 -0
  75. package/build-module/components/post-publish-button/index.js.map +1 -1
  76. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
  77. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  78. package/build-module/components/post-saved-state/index.js +1 -0
  79. package/build-module/components/post-saved-state/index.js.map +1 -1
  80. package/build-module/components/post-schedule/panel.js +1 -1
  81. package/build-module/components/post-schedule/panel.js.map +1 -1
  82. package/build-module/components/post-template/block-theme.js +91 -0
  83. package/build-module/components/post-template/block-theme.js.map +1 -0
  84. package/build-module/components/post-template/classic-theme.js +162 -0
  85. package/build-module/components/post-template/classic-theme.js.map +1 -0
  86. package/build-module/components/post-template/create-new-template-modal.js +91 -0
  87. package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
  88. package/build-module/components/post-template/create-new-template.js +47 -0
  89. package/build-module/components/post-template/create-new-template.js.map +1 -0
  90. package/build-module/components/post-template/hooks.js +78 -0
  91. package/build-module/components/post-template/hooks.js.map +1 -0
  92. package/build-module/components/post-template/panel.js +63 -0
  93. package/build-module/components/post-template/panel.js.map +1 -0
  94. package/build-module/components/post-template/reset-default-template.js +41 -0
  95. package/build-module/components/post-template/reset-default-template.js.map +1 -0
  96. package/build-module/components/post-template/swap-template-button.js +77 -0
  97. package/build-module/components/post-template/swap-template-button.js.map +1 -0
  98. package/build-module/components/post-title/index.native.js +0 -1
  99. package/build-module/components/post-title/index.native.js.map +1 -1
  100. package/build-module/components/preview-dropdown/index.js +105 -0
  101. package/build-module/components/preview-dropdown/index.js.map +1 -0
  102. package/build-module/components/provider/index.js +37 -78
  103. package/build-module/components/provider/index.js.map +1 -1
  104. package/build-module/components/provider/index.native.js +18 -9
  105. package/build-module/components/provider/index.native.js.map +1 -1
  106. package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
  107. package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
  108. package/build-module/components/provider/use-block-editor-settings.js +9 -10
  109. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  110. package/build-module/hooks/index.js +1 -0
  111. package/build-module/hooks/index.js.map +1 -1
  112. package/build-module/hooks/pattern-partial-syncing.js +46 -0
  113. package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
  114. package/build-module/private-apis.js +4 -0
  115. package/build-module/private-apis.js.map +1 -1
  116. package/build-module/store/actions.js +53 -9
  117. package/build-module/store/actions.js.map +1 -1
  118. package/build-module/store/defaults.js +2 -1
  119. package/build-module/store/defaults.js.map +1 -1
  120. package/build-module/store/index.js +3 -0
  121. package/build-module/store/index.js.map +1 -1
  122. package/build-module/store/private-actions.js +44 -0
  123. package/build-module/store/private-actions.js.map +1 -0
  124. package/build-module/store/reducer.js +30 -26
  125. package/build-module/store/reducer.js.map +1 -1
  126. package/build-module/store/reducer.native.js +1 -2
  127. package/build-module/store/reducer.native.js.map +1 -1
  128. package/build-module/store/selectors.js +26 -6
  129. package/build-module/store/selectors.js.map +1 -1
  130. package/build-style/style-rtl.css +182 -0
  131. package/build-style/style.css +182 -0
  132. package/package.json +32 -31
  133. package/src/components/document-bar/index.js +182 -0
  134. package/src/components/document-bar/style.scss +130 -0
  135. package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
  136. package/src/components/editor-canvas/index.js +381 -0
  137. package/src/components/index.js +3 -1
  138. package/src/components/post-publish-button/index.js +1 -0
  139. package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
  140. package/src/components/post-saved-state/index.js +1 -0
  141. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
  142. package/src/components/post-schedule/panel.js +1 -1
  143. package/src/components/post-template/block-theme.js +109 -0
  144. package/src/components/post-template/classic-theme.js +213 -0
  145. package/src/components/post-template/create-new-template-modal.js +139 -0
  146. package/src/components/post-template/create-new-template.js +50 -0
  147. package/src/components/post-template/hooks.js +95 -0
  148. package/src/components/post-template/panel.js +67 -0
  149. package/src/components/post-template/reset-default-template.js +43 -0
  150. package/src/components/post-template/style.scss +52 -0
  151. package/src/components/post-template/swap-template-button.js +83 -0
  152. package/src/components/post-title/index.native.js +0 -1
  153. package/src/components/preview-dropdown/index.js +136 -0
  154. package/src/components/preview-dropdown/style.scss +5 -0
  155. package/src/components/provider/index.js +39 -112
  156. package/src/components/provider/index.native.js +26 -12
  157. package/src/components/provider/navigation-block-editing-mode.js +37 -0
  158. package/src/components/provider/use-block-editor-settings.js +6 -9
  159. package/src/hooks/index.js +1 -0
  160. package/src/hooks/pattern-partial-syncing.js +73 -0
  161. package/src/private-apis.js +4 -0
  162. package/src/store/actions.js +51 -9
  163. package/src/store/defaults.js +1 -0
  164. package/src/store/index.js +3 -0
  165. package/src/store/private-actions.js +61 -0
  166. package/src/store/reducer.js +32 -27
  167. package/src/store/reducer.native.js +0 -2
  168. package/src/store/selectors.js +64 -42
  169. package/src/store/test/selectors.js +88 -147
  170. package/src/style.scss +3 -0
  171. package/build/components/post-template/index.js +0 -66
  172. package/build/components/post-template/index.js.map +0 -1
  173. package/build-module/components/post-template/index.js +0 -57
  174. package/build-module/components/post-template/index.js.map +0 -1
  175. package/src/components/post-template/index.js +0 -64
@@ -1,17 +1,21 @@
1
1
  /**
2
2
  * Internal dependencies
3
3
  */
4
+ import EditorCanvas from './components/editor-canvas';
4
5
  import { ExperimentalEditorProvider } from './components/provider';
5
6
  import { lock } from './lock-unlock';
6
7
  import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
7
8
  import useBlockEditorSettings from './components/provider/use-block-editor-settings';
8
9
  import PostPanelRow from './components/post-panel-row';
10
+ import PreviewDropdown from './components/preview-dropdown';
9
11
 
10
12
  export const privateApis = {};
11
13
  lock( privateApis, {
14
+ EditorCanvas,
12
15
  ExperimentalEditorProvider,
13
16
  EntitiesSavedStatesExtensible,
14
17
  PostPanelRow,
18
+ PreviewDropdown,
15
19
 
16
20
  // This is a temporary private API while we're updating the site editor to use EditorProvider.
17
21
  useBlockEditorSettings,
@@ -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,20 @@ 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
+
572
614
  /**
573
615
  * Backward compatibility
574
616
  */
@@ -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,9 @@ 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';
12
13
  import { STORE_NAME } from './constants';
14
+ import { unlock } from '../lock-unlock';
13
15
 
14
16
  /**
15
17
  * Post editor data store configuration.
@@ -36,3 +38,4 @@ export const store = createReduxStore( STORE_NAME, {
36
38
  } );
37
39
 
38
40
  register( store );
41
+ unlock( store ).registerPrivateActions( privateActions );
@@ -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
+ };
@@ -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;
@@ -237,28 +246,6 @@ export function postAutosavingLock( state = {}, action ) {
237
246
  return state;
238
247
  }
239
248
 
240
- /**
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.
244
- *
245
- * @param {boolean} state
246
- * @param {Object} action
247
- *
248
- * @return {boolean} Updated state.
249
- */
250
- export function isReady( state = false, action ) {
251
- switch ( action.type ) {
252
- case 'SETUP_EDITOR_STATE':
253
- return true;
254
-
255
- case 'TEAR_DOWN_EDITOR':
256
- return false;
257
- }
258
-
259
- return state;
260
- }
261
-
262
249
  /**
263
250
  * Reducer returning the post editor setting.
264
251
  *
@@ -288,16 +275,34 @@ export function renderingMode( state = 'all', action ) {
288
275
  return state;
289
276
  }
290
277
 
278
+ /**
279
+ * Reducer returning the editing canvas device type.
280
+ *
281
+ * @param {Object} state Current state.
282
+ * @param {Object} action Dispatched action.
283
+ *
284
+ * @return {Object} Updated state.
285
+ */
286
+ export function deviceType( state = 'Desktop', action ) {
287
+ switch ( action.type ) {
288
+ case 'SET_DEVICE_TYPE':
289
+ return action.deviceType;
290
+ }
291
+
292
+ return state;
293
+ }
294
+
291
295
  export default combineReducers( {
292
296
  postId,
293
297
  postType,
298
+ templateId,
294
299
  saving,
295
300
  deleting,
296
301
  postLock,
297
302
  template,
298
303
  postSavingLock,
299
- isReady,
300
304
  editorSettings,
301
305
  postAutosavingLock,
302
306
  renderingMode,
307
+ deviceType,
303
308
  } );
@@ -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,
@@ -205,6 +205,17 @@ export function getCurrentPostId( state ) {
205
205
  return state.postId;
206
206
  }
207
207
 
208
+ /**
209
+ * Returns the template ID currently being rendered/edited
210
+ *
211
+ * @param {Object} state Global application state.
212
+ *
213
+ * @return {string?} Template ID.
214
+ */
215
+ export function getCurrentTemplateId( state ) {
216
+ return state.templateId;
217
+ }
218
+
208
219
  /**
209
220
  * Returns the number of revisions of the post currently being edited.
210
221
  *
@@ -819,54 +830,54 @@ export function getEditedPostPreviewLink( state ) {
819
830
  * is a single block within the post and it is of a type known to match a
820
831
  * default post format. Returns null if the format cannot be determined.
821
832
  *
822
- * @param {Object} state Global application state.
823
- *
824
833
  * @return {?string} Suggested post format.
825
834
  */
826
- export function getSuggestedPostFormat( state ) {
827
- const blocks = getEditorBlocks( state );
828
-
829
- if ( blocks.length > 2 ) return null;
830
-
831
- let name;
832
- // If there is only one block in the content of the post grab its name
833
- // so we can derive a suitable post format from it.
834
- if ( blocks.length === 1 ) {
835
- name = blocks[ 0 ].name;
836
- // Check for core/embed `video` and `audio` eligible suggestions.
837
- if ( name === 'core/embed' ) {
838
- const provider = blocks[ 0 ].attributes?.providerNameSlug;
839
- if ( [ 'youtube', 'vimeo' ].includes( provider ) ) {
840
- name = 'core/video';
841
- } else if ( [ 'spotify', 'soundcloud' ].includes( provider ) ) {
842
- name = 'core/audio';
835
+ export const getSuggestedPostFormat = createRegistrySelector(
836
+ ( select ) => () => {
837
+ const blocks = select( blockEditorStore ).getBlocks();
838
+
839
+ if ( blocks.length > 2 ) return null;
840
+
841
+ let name;
842
+ // If there is only one block in the content of the post grab its name
843
+ // so we can derive a suitable post format from it.
844
+ if ( blocks.length === 1 ) {
845
+ name = blocks[ 0 ].name;
846
+ // Check for core/embed `video` and `audio` eligible suggestions.
847
+ if ( name === 'core/embed' ) {
848
+ const provider = blocks[ 0 ].attributes?.providerNameSlug;
849
+ if ( [ 'youtube', 'vimeo' ].includes( provider ) ) {
850
+ name = 'core/video';
851
+ } else if ( [ 'spotify', 'soundcloud' ].includes( provider ) ) {
852
+ name = 'core/audio';
853
+ }
843
854
  }
844
855
  }
845
- }
846
856
 
847
- // If there are two blocks in the content and the last one is a text blocks
848
- // grab the name of the first one to also suggest a post format from it.
849
- if ( blocks.length === 2 && blocks[ 1 ].name === 'core/paragraph' ) {
850
- name = blocks[ 0 ].name;
851
- }
857
+ // If there are two blocks in the content and the last one is a text blocks
858
+ // grab the name of the first one to also suggest a post format from it.
859
+ if ( blocks.length === 2 && blocks[ 1 ].name === 'core/paragraph' ) {
860
+ name = blocks[ 0 ].name;
861
+ }
852
862
 
853
- // We only convert to default post formats in core.
854
- switch ( name ) {
855
- case 'core/image':
856
- return 'image';
857
- case 'core/quote':
858
- case 'core/pullquote':
859
- return 'quote';
860
- case 'core/gallery':
861
- return 'gallery';
862
- case 'core/video':
863
- return 'video';
864
- case 'core/audio':
865
- return 'audio';
866
- default:
867
- return null;
863
+ // We only convert to default post formats in core.
864
+ switch ( name ) {
865
+ case 'core/image':
866
+ return 'image';
867
+ case 'core/quote':
868
+ case 'core/pullquote':
869
+ return 'quote';
870
+ case 'core/gallery':
871
+ return 'gallery';
872
+ case 'core/video':
873
+ return 'video';
874
+ case 'core/audio':
875
+ return 'audio';
876
+ default:
877
+ return null;
878
+ }
868
879
  }
869
- }
880
+ );
870
881
 
871
882
  /**
872
883
  * Returns the content of the post being edited.
@@ -1174,7 +1185,7 @@ export function getEditorSelection( state ) {
1174
1185
  * @return {boolean} is Ready.
1175
1186
  */
1176
1187
  export function __unstableIsEditorReady( state ) {
1177
- return state.isReady;
1188
+ return !! state.postId;
1178
1189
  }
1179
1190
 
1180
1191
  /**
@@ -1199,6 +1210,17 @@ export function getRenderingMode( state ) {
1199
1210
  return state.renderingMode;
1200
1211
  }
1201
1212
 
1213
+ /**
1214
+ * Returns the current editing canvas device type.
1215
+ *
1216
+ * @param {Object} state Global application state.
1217
+ *
1218
+ * @return {string} Device type.
1219
+ */
1220
+ export function getDeviceType( state ) {
1221
+ return state.deviceType;
1222
+ }
1223
+
1202
1224
  /*
1203
1225
  * Backward compatibility
1204
1226
  */