@wordpress/editor 11.0.1-next.253d9b6e21.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/build/components/character-count/index.js +1 -1
  4. package/build/components/character-count/index.js.map +1 -1
  5. package/build/components/editor-help/add-blocks.native.js +6 -5
  6. package/build/components/editor-help/add-blocks.native.js.map +1 -1
  7. package/build/components/editor-help/customize-blocks.native.js +7 -6
  8. package/build/components/editor-help/customize-blocks.native.js.map +1 -1
  9. package/build/components/editor-help/help-detail-navigation-screen.native.js +29 -15
  10. package/build/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  11. package/build/components/editor-help/help-get-support-button.native.js +46 -0
  12. package/build/components/editor-help/help-get-support-button.native.js.map +1 -0
  13. package/build/components/editor-help/help-topic-row.native.js +3 -2
  14. package/build/components/editor-help/help-topic-row.native.js.map +1 -1
  15. package/build/components/editor-help/index.native.js +83 -23
  16. package/build/components/editor-help/index.native.js.map +1 -1
  17. package/build/components/editor-help/intro-to-blocks.native.js +19 -9
  18. package/build/components/editor-help/intro-to-blocks.native.js.map +1 -1
  19. package/build/components/editor-help/move-blocks.native.js +6 -5
  20. package/build/components/editor-help/move-blocks.native.js.map +1 -1
  21. package/build/components/editor-help/remove-blocks.native.js +6 -5
  22. package/build/components/editor-help/remove-blocks.native.js.map +1 -1
  23. package/build/components/editor-help/view-sections.native.js +23 -5
  24. package/build/components/editor-help/view-sections.native.js.map +1 -1
  25. package/build/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
  26. package/build/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  27. package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
  28. package/build/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
  29. package/build/components/index.js +9 -0
  30. package/build/components/index.js.map +1 -1
  31. package/build/components/local-autosave-monitor/index.js +1 -2
  32. package/build/components/local-autosave-monitor/index.js.map +1 -1
  33. package/build/components/post-format/index.js +3 -1
  34. package/build/components/post-format/index.js.map +1 -1
  35. package/build/components/post-locked-modal/index.js +1 -1
  36. package/build/components/post-locked-modal/index.js.map +1 -1
  37. package/build/components/post-saved-state/index.js +37 -46
  38. package/build/components/post-saved-state/index.js.map +1 -1
  39. package/build/components/post-title/index.js +51 -25
  40. package/build/components/post-title/index.js.map +1 -1
  41. package/build/components/provider/index.native.js +18 -7
  42. package/build/components/provider/index.native.js.map +1 -1
  43. package/build/components/provider/use-block-editor-settings.js +32 -5
  44. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  45. package/build/components/word-count/index.js +1 -1
  46. package/build/components/word-count/index.js.map +1 -1
  47. package/build/store/actions.js +13 -38
  48. package/build/store/actions.js.map +1 -1
  49. package/build/store/defaults.js +7 -2
  50. package/build/store/defaults.js.map +1 -1
  51. package/build/store/selectors.js +4 -93
  52. package/build/store/selectors.js.map +1 -1
  53. package/build/{store/utils → utils}/get-template-part-icon.js +0 -0
  54. package/build/utils/get-template-part-icon.js.map +1 -0
  55. package/build/utils/index.js +8 -0
  56. package/build/utils/index.js.map +1 -1
  57. package/build-module/components/character-count/index.js +1 -1
  58. package/build-module/components/character-count/index.js.map +1 -1
  59. package/build-module/components/editor-help/add-blocks.native.js +7 -6
  60. package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
  61. package/build-module/components/editor-help/customize-blocks.native.js +8 -7
  62. package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
  63. package/build-module/components/editor-help/help-detail-navigation-screen.native.js +31 -18
  64. package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  65. package/build-module/components/editor-help/help-get-support-button.native.js +34 -0
  66. package/build-module/components/editor-help/help-get-support-button.native.js.map +1 -0
  67. package/build-module/components/editor-help/help-topic-row.native.js +3 -2
  68. package/build-module/components/editor-help/help-topic-row.native.js.map +1 -1
  69. package/build-module/components/editor-help/index.native.js +77 -25
  70. package/build-module/components/editor-help/index.native.js.map +1 -1
  71. package/build-module/components/editor-help/intro-to-blocks.native.js +19 -10
  72. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  73. package/build-module/components/editor-help/move-blocks.native.js +7 -6
  74. package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
  75. package/build-module/components/editor-help/remove-blocks.native.js +7 -6
  76. package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
  77. package/build-module/components/editor-help/view-sections.native.js +22 -5
  78. package/build-module/components/editor-help/view-sections.native.js.map +1 -1
  79. package/build-module/components/global-keyboard-shortcuts/save-shortcut.js +12 -14
  80. package/build-module/components/global-keyboard-shortcuts/save-shortcut.js.map +1 -1
  81. package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +0 -4
  82. package/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js.map +1 -1
  83. package/build-module/components/index.js +1 -0
  84. package/build-module/components/index.js.map +1 -1
  85. package/build-module/components/local-autosave-monitor/index.js +1 -2
  86. package/build-module/components/local-autosave-monitor/index.js.map +1 -1
  87. package/build-module/components/post-format/index.js +4 -2
  88. package/build-module/components/post-format/index.js.map +1 -1
  89. package/build-module/components/post-locked-modal/index.js +1 -1
  90. package/build-module/components/post-locked-modal/index.js.map +1 -1
  91. package/build-module/components/post-saved-state/index.js +38 -46
  92. package/build-module/components/post-saved-state/index.js.map +1 -1
  93. package/build-module/components/post-title/index.js +51 -22
  94. package/build-module/components/post-title/index.js.map +1 -1
  95. package/build-module/components/provider/index.native.js +18 -7
  96. package/build-module/components/provider/index.native.js.map +1 -1
  97. package/build-module/components/provider/use-block-editor-settings.js +31 -5
  98. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  99. package/build-module/components/word-count/index.js +1 -1
  100. package/build-module/components/word-count/index.js.map +1 -1
  101. package/build-module/store/actions.js +13 -36
  102. package/build-module/store/actions.js.map +1 -1
  103. package/build-module/store/defaults.js +7 -2
  104. package/build-module/store/defaults.js.map +1 -1
  105. package/build-module/store/selectors.js +3 -85
  106. package/build-module/store/selectors.js.map +1 -1
  107. package/build-module/{store/utils → utils}/get-template-part-icon.js +0 -0
  108. package/build-module/utils/get-template-part-icon.js.map +1 -0
  109. package/build-module/utils/index.js +1 -0
  110. package/build-module/utils/index.js.map +1 -1
  111. package/build-style/style-rtl.css +9 -60
  112. package/build-style/style.css +9 -60
  113. package/package.json +30 -30
  114. package/src/components/character-count/index.js +3 -2
  115. package/src/components/editor-help/add-blocks.native.js +17 -12
  116. package/src/components/editor-help/customize-blocks.native.js +16 -13
  117. package/src/components/editor-help/help-detail-navigation-screen.native.js +45 -15
  118. package/src/components/editor-help/help-get-support-button.native.js +38 -0
  119. package/src/components/editor-help/help-topic-row.native.js +2 -2
  120. package/src/components/editor-help/images/add-dark.png +0 -0
  121. package/src/components/editor-help/images/add-dark@2x.png +0 -0
  122. package/src/components/editor-help/images/add-dark@3x.png +0 -0
  123. package/src/components/editor-help/images/add-light.png +0 -0
  124. package/src/components/editor-help/images/add-light@2x.png +0 -0
  125. package/src/components/editor-help/images/add-light@3x.png +0 -0
  126. package/src/components/editor-help/images/block-layout-collage.png +0 -0
  127. package/src/components/editor-help/images/block-layout-collage@2x.png +0 -0
  128. package/src/components/editor-help/images/block-layout-collage@3x.png +0 -0
  129. package/src/components/editor-help/images/build-layouts-dark.png +0 -0
  130. package/src/components/editor-help/images/build-layouts-dark@2x.png +0 -0
  131. package/src/components/editor-help/images/build-layouts-dark@3x.png +0 -0
  132. package/src/components/editor-help/images/build-layouts-light.png +0 -0
  133. package/src/components/editor-help/images/build-layouts-light@2x.png +0 -0
  134. package/src/components/editor-help/images/build-layouts-light@3x.png +0 -0
  135. package/src/components/editor-help/images/edit-media-dark.png +0 -0
  136. package/src/components/editor-help/images/edit-media-dark@2x.png +0 -0
  137. package/src/components/editor-help/images/edit-media-dark@3x.png +0 -0
  138. package/src/components/editor-help/images/edit-media-light.png +0 -0
  139. package/src/components/editor-help/images/edit-media-light@2x.png +0 -0
  140. package/src/components/editor-help/images/edit-media-light@3x.png +0 -0
  141. package/src/components/editor-help/images/embed-media-dark.png +0 -0
  142. package/src/components/editor-help/images/embed-media-dark@2x.png +0 -0
  143. package/src/components/editor-help/images/embed-media-dark@3x.png +0 -0
  144. package/src/components/editor-help/images/embed-media-light.png +0 -0
  145. package/src/components/editor-help/images/embed-media-light@2x.png +0 -0
  146. package/src/components/editor-help/images/embed-media-light@3x.png +0 -0
  147. package/src/components/editor-help/images/move-dark.png +0 -0
  148. package/src/components/editor-help/images/move-dark@2x.png +0 -0
  149. package/src/components/editor-help/images/move-dark@3x.png +0 -0
  150. package/src/components/editor-help/images/move-light.png +0 -0
  151. package/src/components/editor-help/images/move-light@2x.png +0 -0
  152. package/src/components/editor-help/images/move-light@3x.png +0 -0
  153. package/src/components/editor-help/images/options-dark.png +0 -0
  154. package/src/components/editor-help/images/options-dark@2x.png +0 -0
  155. package/src/components/editor-help/images/options-dark@3x.png +0 -0
  156. package/src/components/editor-help/images/options-light.png +0 -0
  157. package/src/components/editor-help/images/options-light@2x.png +0 -0
  158. package/src/components/editor-help/images/options-light@3x.png +0 -0
  159. package/src/components/editor-help/images/rich-text-dark.png +0 -0
  160. package/src/components/editor-help/images/rich-text-dark@2x.png +0 -0
  161. package/src/components/editor-help/images/rich-text-dark@3x.png +0 -0
  162. package/src/components/editor-help/images/rich-text-light.png +0 -0
  163. package/src/components/editor-help/images/rich-text-light@2x.png +0 -0
  164. package/src/components/editor-help/images/rich-text-light@3x.png +0 -0
  165. package/src/components/editor-help/images/settings-dark.png +0 -0
  166. package/src/components/editor-help/images/settings-dark@2x.png +0 -0
  167. package/src/components/editor-help/images/settings-dark@3x.png +0 -0
  168. package/src/components/editor-help/images/settings-light.png +0 -0
  169. package/src/components/editor-help/images/settings-light@2x.png +0 -0
  170. package/src/components/editor-help/images/settings-light@3x.png +0 -0
  171. package/src/components/editor-help/index.native.js +129 -35
  172. package/src/components/editor-help/intro-to-blocks.native.js +63 -43
  173. package/src/components/editor-help/move-blocks.native.js +12 -7
  174. package/src/components/editor-help/remove-blocks.native.js +11 -8
  175. package/src/components/editor-help/style.android.scss +6 -0
  176. package/src/components/editor-help/style.ios.scss +6 -0
  177. package/src/components/editor-help/style.scss +47 -34
  178. package/src/components/editor-help/test/index.native.js +80 -0
  179. package/src/components/editor-help/view-sections.native.js +47 -4
  180. package/src/components/global-keyboard-shortcuts/save-shortcut.js +34 -42
  181. package/src/components/global-keyboard-shortcuts/visual-editor-shortcuts.js +8 -16
  182. package/src/components/index.js +1 -0
  183. package/src/components/local-autosave-monitor/index.js +1 -3
  184. package/src/components/post-format/index.js +6 -2
  185. package/src/components/post-format/style.scss +1 -0
  186. package/src/components/post-locked-modal/index.js +1 -1
  187. package/src/components/post-saved-state/index.js +41 -55
  188. package/src/components/post-saved-state/style.scss +8 -1
  189. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +20 -0
  190. package/src/components/post-saved-state/test/index.js +2 -2
  191. package/src/components/post-title/index.js +45 -30
  192. package/src/components/post-title/style.scss +1 -70
  193. package/src/components/provider/index.native.js +17 -5
  194. package/src/components/provider/use-block-editor-settings.js +25 -0
  195. package/src/components/word-count/index.js +3 -2
  196. package/src/store/actions.js +13 -41
  197. package/src/store/defaults.js +7 -2
  198. package/src/store/selectors.js +2 -112
  199. package/src/{store/utils → utils}/get-template-part-icon.js +0 -0
  200. package/src/utils/index.js +1 -0
  201. package/build/store/utils/get-template-part-icon.js.map +0 -1
  202. package/build-module/store/utils/get-template-part-icon.js.map +0 -1
  203. package/src/components/editor-help/images/add-blocks.png +0 -0
  204. package/src/components/editor-help/images/customize-blocks.png +0 -0
  205. package/src/components/editor-help/images/cut-copy-duplicate-blocks.png +0 -0
  206. package/src/components/editor-help/images/edit-or-replace-media.png +0 -0
  207. package/src/components/editor-help/images/intro-blocks-1.png +0 -0
  208. package/src/components/editor-help/images/intro-blocks-2.png +0 -0
  209. package/src/components/editor-help/images/intro-blocks-3.png +0 -0
  210. package/src/components/editor-help/images/intro-blocks-4.png +0 -0
  211. package/src/components/editor-help/images/move-blocks.png +0 -0
  212. package/src/components/editor-help/images/remove-blocks.png +0 -0
  213. package/src/components/editor-help/images/what-is-a-block.png +0 -0
@@ -12,51 +12,43 @@ import { store as editorStore } from '../../store';
12
12
 
13
13
  function SaveShortcut( { resetBlocksOnSave } ) {
14
14
  const { resetEditorBlocks, savePost } = useDispatch( editorStore );
15
- const { isEditedPostDirty, getPostEdits } = useSelect( ( select ) => {
16
- const {
17
- isEditedPostDirty: _isEditedPostDirty,
18
- getPostEdits: _getPostEdits,
19
- } = select( editorStore );
20
-
21
- return {
22
- isEditedPostDirty: _isEditedPostDirty,
23
- getPostEdits: _getPostEdits,
24
- };
25
- }, [] );
26
-
27
- useShortcut(
28
- 'core/editor/save',
29
- ( event ) => {
30
- event.preventDefault();
31
-
32
- // TODO: This should be handled in the `savePost` effect in
33
- // considering `isSaveable`. See note on `isEditedPostSaveable`
34
- // selector about dirtiness and meta-boxes.
35
- //
36
- // See: `isEditedPostSaveable`
37
- if ( ! isEditedPostDirty() ) {
38
- return;
39
- }
15
+ const { isEditedPostDirty, getPostEdits, isPostSavingLocked } = useSelect(
16
+ editorStore
17
+ );
40
18
 
41
- // The text editor requires that editor blocks are updated for a
42
- // save to work correctly. Usually this happens when the textarea
43
- // for the code editors blurs, but the shortcut can be used without
44
- // blurring the textarea.
45
- if ( resetBlocksOnSave ) {
46
- const postEdits = getPostEdits();
47
- if (
48
- postEdits.content &&
49
- typeof postEdits.content === 'string'
50
- ) {
51
- const blocks = parse( postEdits.content );
52
- resetEditorBlocks( blocks );
53
- }
19
+ useShortcut( 'core/editor/save', ( event ) => {
20
+ event.preventDefault();
21
+
22
+ /**
23
+ * Do not save the post if post saving is locked.
24
+ */
25
+ if ( isPostSavingLocked() ) {
26
+ return;
27
+ }
28
+
29
+ // TODO: This should be handled in the `savePost` effect in
30
+ // considering `isSaveable`. See note on `isEditedPostSaveable`
31
+ // selector about dirtiness and meta-boxes.
32
+ //
33
+ // See: `isEditedPostSaveable`
34
+ if ( ! isEditedPostDirty() ) {
35
+ return;
36
+ }
37
+
38
+ // The text editor requires that editor blocks are updated for a
39
+ // save to work correctly. Usually this happens when the textarea
40
+ // for the code editors blurs, but the shortcut can be used without
41
+ // blurring the textarea.
42
+ if ( resetBlocksOnSave ) {
43
+ const postEdits = getPostEdits();
44
+ if ( postEdits.content && typeof postEdits.content === 'string' ) {
45
+ const blocks = parse( postEdits.content );
46
+ resetEditorBlocks( blocks );
54
47
  }
48
+ }
55
49
 
56
- savePost();
57
- },
58
- { bindGlobal: true }
59
- );
50
+ savePost();
51
+ } );
60
52
 
61
53
  return null;
62
54
  }
@@ -13,23 +13,15 @@ import { store as editorStore } from '../../store';
13
13
  function VisualEditorGlobalKeyboardShortcuts() {
14
14
  const { redo, undo } = useDispatch( editorStore );
15
15
 
16
- useShortcut(
17
- 'core/editor/undo',
18
- ( event ) => {
19
- undo();
20
- event.preventDefault();
21
- },
22
- { bindGlobal: true }
23
- );
16
+ useShortcut( 'core/editor/undo', ( event ) => {
17
+ undo();
18
+ event.preventDefault();
19
+ } );
24
20
 
25
- useShortcut(
26
- 'core/editor/redo',
27
- ( event ) => {
28
- redo();
29
- event.preventDefault();
30
- },
31
- { bindGlobal: true }
32
- );
21
+ useShortcut( 'core/editor/redo', ( event ) => {
22
+ redo();
23
+ event.preventDefault();
24
+ } );
33
25
 
34
26
  return <SaveShortcut />;
35
27
  }
@@ -58,6 +58,7 @@ export { default as PostVisibility } from './post-visibility';
58
58
  export { default as PostVisibilityLabel } from './post-visibility/label';
59
59
  export { default as PostVisibilityCheck } from './post-visibility/check';
60
60
  export { default as TableOfContents } from './table-of-contents';
61
+ export { default as ThemeSupportCheck } from './theme-support-check';
61
62
  export { default as UnsavedChangesWarning } from './unsaved-changes-warning';
62
63
  export { default as WordCount } from './word-count';
63
64
 
@@ -51,14 +51,12 @@ function useAutosaveNotice() {
51
51
  ( select ) => ( {
52
52
  postId: select( editorStore ).getCurrentPostId(),
53
53
  isEditedPostNew: select( editorStore ).isEditedPostNew(),
54
- getEditedPostAttribute: select( editorStore )
55
- .getEditedPostAttribute,
56
54
  hasRemoteAutosave: !! select( editorStore ).getEditorSettings()
57
55
  .autosave,
58
56
  } ),
59
57
  []
60
58
  );
61
- const { getEditedPostAttribute } = useSelect( 'core/editor' );
59
+ const { getEditedPostAttribute } = useSelect( editorStore );
62
60
 
63
61
  const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
64
62
  const { editPost, resetEditorBlocks } = useDispatch( editorStore );
@@ -6,7 +6,7 @@ import { find, get, includes, union } from 'lodash';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { __ } from '@wordpress/i18n';
9
+ import { __, sprintf } from '@wordpress/i18n';
10
10
  import { Button, SelectControl } from '@wordpress/components';
11
11
  import { useDispatch, useSelect } from '@wordpress/data';
12
12
  import { useInstanceId } from '@wordpress/compose';
@@ -107,7 +107,11 @@ export default function PostFormat() {
107
107
  onUpdatePostFormat( suggestion.id )
108
108
  }
109
109
  >
110
- { suggestion.caption }
110
+ { sprintf(
111
+ /* translators: %s: post format */
112
+ __( 'Apply format: %s' ),
113
+ suggestion.caption
114
+ ) }
111
115
  </Button>
112
116
  </div>
113
117
  ) }
@@ -12,6 +12,7 @@
12
12
  }
13
13
 
14
14
  .editor-post-format__suggestion {
15
+ padding: $grid-unit-15 * 0.5;
15
16
  text-align: right;
16
17
  font-size: $default-font-size;
17
18
  }
@@ -54,7 +54,7 @@ export default function PostLockedModal() {
54
54
  activePostLock: getActivePostLock(),
55
55
  postType: getPostType( getEditedPostAttribute( 'type' ) ),
56
56
  };
57
- } );
57
+ }, [] );
58
58
 
59
59
  useEffect( () => {
60
60
  /**
@@ -100,79 +100,65 @@ export default function PostSavedState( {
100
100
  return () => clearTimeout( timeoutId );
101
101
  }, [ isSaving ] );
102
102
 
103
- if ( isSaving ) {
104
- // TODO: Classes generation should be common across all return
105
- // paths of this function, including proper naming convention for
106
- // the "Save Draft" button.
107
- const classes = classnames(
108
- 'editor-post-saved-state',
109
- 'is-saving',
110
- getAnimateClassName( { type: 'loading' } ),
111
- {
112
- 'is-autosaving': isAutosaving,
113
- }
114
- );
115
-
116
- return (
117
- <span className={ classes }>
118
- <Icon icon={ cloud } />
119
- { isAutosaving ? __( 'Autosaving' ) : __( 'Saving' ) }
120
- </span>
121
- );
122
- }
123
-
124
- if ( isPublished || isScheduled ) {
125
- return <PostSwitchToDraftButton />;
126
- }
127
-
128
- if ( ! isSaveable ) {
129
- return null;
130
- }
131
-
132
- if ( forceSavedMessage || ( ! isNew && ! isDirty ) ) {
133
- return (
134
- <span className="editor-post-saved-state is-saved">
135
- <Icon icon={ check } />
136
- { __( 'Saved' ) }
137
- </span>
138
- );
139
- }
140
-
141
103
  // Once the post has been submitted for review this button
142
104
  // is not needed for the contributor role.
143
-
144
105
  if ( ! hasPublishAction && isPending ) {
145
106
  return null;
146
107
  }
147
108
 
109
+ if ( isPublished || isScheduled ) {
110
+ return <PostSwitchToDraftButton />;
111
+ }
112
+
148
113
  /* translators: button label text should, if possible, be under 16 characters. */
149
114
  const label = isPending ? __( 'Save as pending' ) : __( 'Save draft' );
150
115
 
151
116
  /* translators: button label text should, if possible, be under 16 characters. */
152
117
  const shortLabel = __( 'Save' );
153
118
 
154
- if ( ! isLargeViewport ) {
155
- return (
156
- <Button
157
- className="editor-post-save-draft"
158
- label={ label }
159
- onClick={ () => savePost() }
160
- shortcut={ displayShortcut.primary( 's' ) }
161
- icon={ cloudUpload }
162
- >
163
- { showIconLabels && shortLabel }
164
- </Button>
165
- );
119
+ const isSaved = forceSavedMessage || ( ! isNew && ! isDirty );
120
+ const isSavedState = isSaving || isSaved;
121
+ const isDisabled = isSaving || isSaved || ! isSaveable;
122
+
123
+ let text;
124
+
125
+ if ( isSaving ) {
126
+ text = isAutosaving ? __( 'Autosaving' ) : __( 'Saving' );
127
+ } else if ( isSaved ) {
128
+ text = __( 'Saved' );
129
+ } else if ( isLargeViewport ) {
130
+ text = label;
131
+ } else if ( showIconLabels ) {
132
+ text = shortLabel;
166
133
  }
167
134
 
135
+ // Use common Button instance for all saved states so that focus is not
136
+ // lost.
168
137
  return (
169
138
  <Button
170
- className="editor-post-save-draft"
171
- onClick={ () => savePost() }
139
+ className={
140
+ isSaveable || isSaving
141
+ ? classnames( {
142
+ 'editor-post-save-draft': ! isSavedState,
143
+ 'editor-post-saved-state': isSavedState,
144
+ 'is-saving': isSaving,
145
+ 'is-autosaving': isAutosaving,
146
+ 'is-saved': isSaved,
147
+ [ getAnimateClassName( {
148
+ type: 'loading',
149
+ } ) ]: isSaving,
150
+ } )
151
+ : undefined
152
+ }
153
+ onClick={ isDisabled ? undefined : () => savePost() }
172
154
  shortcut={ displayShortcut.primary( 's' ) }
173
- variant="tertiary"
155
+ variant={ isLargeViewport ? 'tertiary' : undefined }
156
+ icon={ isLargeViewport ? undefined : cloudUpload }
157
+ label={ label }
158
+ aria-disabled={ isDisabled }
174
159
  >
175
- { label }
160
+ { isSavedState && <Icon icon={ isSaved ? check : cloud } /> }
161
+ { text }
176
162
  </Button>
177
163
  );
178
164
  }
@@ -7,6 +7,13 @@
7
7
  overflow: hidden;
8
8
  white-space: nowrap;
9
9
 
10
+ // The disabled version of the save state should be legible as an indicator.
11
+ &.is-saved[aria-disabled="true"],
12
+ &.is-saved[aria-disabled="true"]:hover {
13
+ background: transparent;
14
+ color: $gray-700;
15
+ }
16
+
10
17
  svg {
11
18
  display: inline-block;
12
19
  flex: 0 0 auto;
@@ -20,7 +27,7 @@
20
27
  text-indent: inherit;
21
28
 
22
29
  svg {
23
- margin-right: $grid-unit-05;
30
+ margin-right: 0;
24
31
  }
25
32
  }
26
33
  }
@@ -1,10 +1,30 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`PostSavedState returns a disabled button if the post is not saveable 1`] = `
4
+ <ForwardRef(Button)
5
+ aria-disabled={true}
6
+ icon={
7
+ <SVG
8
+ viewBox="0 0 24 24"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ >
11
+ <Path
12
+ d="M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z"
13
+ />
14
+ </SVG>
15
+ }
16
+ label="Save draft"
17
+ shortcut="Ctrl+S"
18
+ />
19
+ `;
20
+
3
21
  exports[`PostSavedState returns a switch to draft link if the post is published 1`] = `<WithSelect(WithDispatch(PostSwitchToDraftButton)) />`;
4
22
 
5
23
  exports[`PostSavedState should return Save button if edits to be saved 1`] = `
6
24
  <ForwardRef(Button)
25
+ aria-disabled={false}
7
26
  className="editor-post-save-draft"
27
+ label="Save draft"
8
28
  onClick={[Function]}
9
29
  shortcut="Ctrl+S"
10
30
  variant="tertiary"
@@ -48,7 +48,7 @@ describe( 'PostSavedState', () => {
48
48
  expect( wrapper.text() ).toContain( 'Saving' );
49
49
  } );
50
50
 
51
- it( 'returns null if the post is not saveable', () => {
51
+ it( 'returns a disabled button if the post is not saveable', () => {
52
52
  useSelect.mockImplementation( () => ( {
53
53
  isDirty: false,
54
54
  isNew: true,
@@ -58,7 +58,7 @@ describe( 'PostSavedState', () => {
58
58
 
59
59
  const wrapper = shallow( <PostSavedState /> );
60
60
 
61
- expect( wrapper.type() ).toBeNull();
61
+ expect( wrapper ).toMatchSnapshot();
62
62
  } );
63
63
 
64
64
  it( 'returns a switch to draft link if the post is published', () => {
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import TextareaAutosize from 'react-autosize-textarea';
5
4
  import classnames from 'classnames';
6
5
 
7
6
  /**
@@ -12,10 +11,10 @@ import { useEffect, useRef, useState } from '@wordpress/element';
12
11
  import { decodeEntities } from '@wordpress/html-entities';
13
12
  import { ENTER } from '@wordpress/keycodes';
14
13
  import { useSelect, useDispatch } from '@wordpress/data';
15
- import { VisuallyHidden } from '@wordpress/components';
16
- import { useInstanceId } from '@wordpress/compose';
17
14
  import { pasteHandler } from '@wordpress/blocks';
18
15
  import { store as blockEditorStore } from '@wordpress/block-editor';
16
+ import { __unstableUseRichText as useRichText } from '@wordpress/rich-text';
17
+ import { useMergeRefs } from '@wordpress/compose';
19
18
 
20
19
  /**
21
20
  * Internal dependencies
@@ -29,7 +28,6 @@ import { store as editorStore } from '../../store';
29
28
  const REGEXP_NEWLINES = /[\r\n]+/g;
30
29
 
31
30
  export default function PostTitle() {
32
- const instanceId = useInstanceId( PostTitle );
33
31
  const ref = useRef();
34
32
  const [ isSelected, setIsSelected ] = useState( false );
35
33
  const { editPost } = useDispatch( editorStore );
@@ -63,7 +61,7 @@ export default function PostTitle() {
63
61
  isFocusMode: focusMode,
64
62
  hasFixedToolbar: _hasFixedToolbar,
65
63
  };
66
- } );
64
+ }, [] );
67
65
 
68
66
  useEffect( () => {
69
67
  if ( ! ref.current ) {
@@ -94,6 +92,8 @@ export default function PostTitle() {
94
92
  editPost( { title: newTitle } );
95
93
  }
96
94
 
95
+ const [ selection, setSelection ] = useState( {} );
96
+
97
97
  function onSelect() {
98
98
  setIsSelected( true );
99
99
  clearSelectedBlock();
@@ -101,10 +101,11 @@ export default function PostTitle() {
101
101
 
102
102
  function onUnselect() {
103
103
  setIsSelected( false );
104
+ setSelection( {} );
104
105
  }
105
106
 
106
- function onChange( event ) {
107
- onUpdate( event.target.value.replace( REGEXP_NEWLINES, ' ' ) );
107
+ function onChange( value ) {
108
+ onUpdate( value.replace( REGEXP_NEWLINES, ' ' ) );
108
109
  }
109
110
 
110
111
  function onKeyDown( event ) {
@@ -167,38 +168,52 @@ export default function PostTitle() {
167
168
  // The wp-block className is important for editor styles.
168
169
  // This same block is used in both the visual and the code editor.
169
170
  const className = classnames(
170
- 'wp-block editor-post-title editor-post-title__block',
171
+ 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text',
171
172
  {
172
173
  'is-selected': isSelected,
173
174
  'is-focus-mode': isFocusMode,
174
175
  'has-fixed-toolbar': hasFixedToolbar,
175
176
  }
176
177
  );
177
- const decodedPlaceholder = decodeEntities( placeholder );
178
+ const decodedPlaceholder =
179
+ decodeEntities( placeholder ) || __( 'Add title' );
180
+ const { ref: richTextRef } = useRichText( {
181
+ value: title,
182
+ onChange,
183
+ placeholder: decodedPlaceholder,
184
+ selectionStart: selection.start,
185
+ selectionEnd: selection.end,
186
+ onSelectionChange( newStart, newEnd ) {
187
+ setSelection( ( sel ) => {
188
+ const { start, end } = sel;
189
+ if ( start === newStart && end === newEnd ) {
190
+ return sel;
191
+ }
192
+ return {
193
+ start: newStart,
194
+ end: newEnd,
195
+ };
196
+ } );
197
+ },
198
+ __unstableDisableFormats: true,
199
+ preserveWhiteSpace: true,
200
+ } );
178
201
 
202
+ /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-interactions */
179
203
  return (
180
204
  <PostTypeSupportCheck supportKeys="title">
181
- <div className={ className }>
182
- <VisuallyHidden
183
- as="label"
184
- htmlFor={ `post-title-${ instanceId }` }
185
- >
186
- { decodedPlaceholder || __( 'Add title' ) }
187
- </VisuallyHidden>
188
- <TextareaAutosize
189
- ref={ ref }
190
- id={ `post-title-${ instanceId }` }
191
- className="editor-post-title__input"
192
- value={ title }
193
- onChange={ onChange }
194
- placeholder={ decodedPlaceholder || __( 'Add title' ) }
195
- onFocus={ onSelect }
196
- onBlur={ onUnselect }
197
- onKeyDown={ onKeyDown }
198
- onKeyPress={ onUnselect }
199
- onPaste={ onPaste }
200
- />
201
- </div>
205
+ <h1
206
+ ref={ useMergeRefs( [ richTextRef, ref ] ) }
207
+ contentEditable
208
+ className={ className }
209
+ aria-label={ decodedPlaceholder }
210
+ onFocus={ onSelect }
211
+ onBlur={ onUnselect }
212
+ onKeyDown={ onKeyDown }
213
+ onKeyPress={ onUnselect }
214
+ onPaste={ onPaste }
215
+ />
202
216
  </PostTypeSupportCheck>
203
217
  );
218
+ /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-interactions */
204
219
  }
@@ -1,76 +1,7 @@
1
1
  .editor-post-title {
2
2
  position: relative;
3
3
 
4
- .editor-post-title__input {
5
- display: block;
6
- width: 100%;
7
- margin: 0;
8
- box-shadow: none;
9
- background: transparent;
10
- transition: border 0.1s ease-out, box-shadow 0.1s linear;
11
- @include reduce-motion("transition");
12
- padding: #{ $block-padding + 5px } 0;
13
- word-break: keep-all;
14
-
15
- // Inherit the styles set by the theme.
16
- font-family: inherit;
17
- color: inherit;
18
-
19
- // Stack borders on mobile.
20
- border: $border-width solid transparent;
21
- border-left-width: 0;
22
- border-right-width: 0;
23
- border-radius: 0;
24
-
25
- // Include transparent outline for Windows High Contrast mode.
26
- outline: $border-width solid transparent;
27
-
28
- @include break-small() {
29
- border-width: $border-width;
30
- }
31
-
32
- // Match h1 heading.
33
- font-size: 2.44em;
34
- font-weight: 800;
35
- line-height: 1.4;
36
-
37
- &::-webkit-input-placeholder {
38
- color: $dark-gray-placeholder;
39
- }
40
-
41
- &::-moz-placeholder {
42
- color: $dark-gray-placeholder;
43
- // Override Firefox default.
44
- opacity: 1;
45
- }
46
-
47
- &:-ms-input-placeholder {
48
- color: $dark-gray-placeholder;
49
- }
50
-
51
- .is-dark-theme & {
52
- &::-webkit-input-placeholder {
53
- color: $light-gray-placeholder;
54
- }
55
-
56
- &::-moz-placeholder {
57
- opacity: 1; // Necessary because Firefox reduces this from 1.
58
- color: $light-gray-placeholder;
59
- }
60
-
61
- &:-ms-input-placeholder {
62
- color: $light-gray-placeholder;
63
- }
64
- }
65
-
66
- &:focus {
67
- border: $border-width solid transparent;
68
- outline: $border-width solid transparent;
69
- box-shadow: none;
70
- }
71
- }
72
-
73
- &.is-focus-mode .editor-post-title__input {
4
+ &.is-focus-mode {
74
5
  opacity: 0.5;
75
6
  transition: opacity 0.1s linear;
76
7
  @include reduce-motion("transition");
@@ -54,6 +54,7 @@ const postTypeEntities = [
54
54
  mergedEdits: {
55
55
  meta: true,
56
56
  },
57
+ rawAttributes: [ 'title', 'excerpt', 'content' ],
57
58
  } ) );
58
59
  import { EditorHelpTopics } from '@wordpress/editor';
59
60
 
@@ -89,11 +90,18 @@ class NativeEditorProvider extends Component {
89
90
  }
90
91
 
91
92
  componentDidMount() {
92
- const { capabilities, updateSettings } = this.props;
93
+ const {
94
+ capabilities,
95
+ locale,
96
+ updateSettings,
97
+ galleryWithImageBlocks,
98
+ } = this.props;
93
99
 
94
100
  updateSettings( {
95
101
  ...capabilities,
102
+ ...{ __unstableGalleryWithImageBlocks: galleryWithImageBlocks },
96
103
  ...this.getThemeColors( this.props ),
104
+ locale,
97
105
  } );
98
106
 
99
107
  this.subscriptionParentGetHtml = subscribeParentGetHtml( () => {
@@ -142,8 +150,13 @@ class NativeEditorProvider extends Component {
142
150
 
143
151
  this.subscriptionParentUpdateEditorSettings = subscribeUpdateEditorSettings(
144
152
  ( editorSettings ) => {
145
- const themeColors = this.getThemeColors( editorSettings );
146
- updateSettings( themeColors );
153
+ updateSettings( {
154
+ ...{
155
+ __unstableGalleryWithImageBlocks:
156
+ editorSettings.galleryWithImageBlocks,
157
+ },
158
+ ...this.getThemeColors( editorSettings ),
159
+ } );
147
160
  }
148
161
  );
149
162
 
@@ -160,8 +173,6 @@ class NativeEditorProvider extends Component {
160
173
  );
161
174
 
162
175
  this.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {
163
- // Temporary: feature hidden from production. This is just here for testing
164
- // purposes and will be replaced with actual logic in a later PR.
165
176
  this.setState( { isHelpVisible: true } );
166
177
  } );
167
178
 
@@ -333,6 +344,7 @@ class NativeEditorProvider extends Component {
333
344
  <EditorHelpTopics
334
345
  isVisible={ this.state.isHelpVisible }
335
346
  onClose={ () => this.setState( { isHelpVisible: false } ) }
347
+ close={ () => this.setState( { isHelpVisible: false } ) }
336
348
  />
337
349
  </>
338
350
  );