@wordpress/editor 13.8.0 → 13.10.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 (45) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/entities-saved-states/index.js +59 -13
  3. package/build/components/entities-saved-states/index.js.map +1 -1
  4. package/build/components/post-featured-image/index.js +24 -29
  5. package/build/components/post-featured-image/index.js.map +1 -1
  6. package/build/components/post-saved-state/index.js +0 -8
  7. package/build/components/post-saved-state/index.js.map +1 -1
  8. package/build/components/post-switch-to-draft-button/index.js +9 -4
  9. package/build/components/post-switch-to-draft-button/index.js.map +1 -1
  10. package/build/components/post-template/index.js +1 -7
  11. package/build/components/post-template/index.js.map +1 -1
  12. package/build/components/post-title/index.native.js +41 -11
  13. package/build/components/post-title/index.native.js.map +1 -1
  14. package/build/hooks/custom-sources-backwards-compatibility.js +2 -8
  15. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  16. package/build-module/components/entities-saved-states/index.js +60 -13
  17. package/build-module/components/entities-saved-states/index.js.map +1 -1
  18. package/build-module/components/post-featured-image/index.js +26 -32
  19. package/build-module/components/post-featured-image/index.js.map +1 -1
  20. package/build-module/components/post-saved-state/index.js +0 -7
  21. package/build-module/components/post-saved-state/index.js.map +1 -1
  22. package/build-module/components/post-switch-to-draft-button/index.js +12 -7
  23. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  24. package/build-module/components/post-template/index.js +1 -6
  25. package/build-module/components/post-template/index.js.map +1 -1
  26. package/build-module/components/post-title/index.native.js +41 -11
  27. package/build-module/components/post-title/index.native.js.map +1 -1
  28. package/build-module/hooks/custom-sources-backwards-compatibility.js +2 -7
  29. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  30. package/build-style/style-rtl.css +37 -15
  31. package/build-style/style.css +37 -15
  32. package/package.json +31 -32
  33. package/src/components/entities-saved-states/index.js +65 -21
  34. package/src/components/post-featured-image/index.js +26 -35
  35. package/src/components/post-featured-image/style.scss +38 -14
  36. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +3 -1
  37. package/src/components/post-saved-state/index.js +0 -7
  38. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -9
  39. package/src/components/post-saved-state/test/index.js +0 -10
  40. package/src/components/post-switch-to-draft-button/index.js +7 -6
  41. package/src/components/post-taxonomies/style.scss +4 -4
  42. package/src/components/post-template/index.js +5 -6
  43. package/src/components/post-title/index.native.js +31 -8
  44. package/src/components/post-trash/style.scss +1 -3
  45. package/src/hooks/custom-sources-backwards-compatibility.js +2 -7
@@ -67,16 +67,6 @@ describe( 'PostSavedState', () => {
67
67
  expect( screen.getByRole( 'button' ) ).toMatchSnapshot();
68
68
  } );
69
69
 
70
- it( 'returns a switch to draft link if the post is published', () => {
71
- useSelect.mockImplementation( () => ( {
72
- isPublished: true,
73
- } ) );
74
-
75
- render( <PostSavedState /> );
76
-
77
- expect( screen.getByRole( 'button' ) ).toMatchSnapshot();
78
- } );
79
-
80
70
  it( 'should return Saved text if not new and not dirty', () => {
81
71
  useSelect.mockImplementation( () => ( {
82
72
  isDirty: false,
@@ -3,11 +3,12 @@
3
3
  */
4
4
  import {
5
5
  Button,
6
+ FlexItem,
6
7
  __experimentalConfirmDialog as ConfirmDialog,
7
8
  } from '@wordpress/components';
8
9
  import { __ } from '@wordpress/i18n';
9
10
  import { withSelect, withDispatch } from '@wordpress/data';
10
- import { compose, useViewportMatch } from '@wordpress/compose';
11
+ import { compose } from '@wordpress/compose';
11
12
  import { useState } from '@wordpress/element';
12
13
 
13
14
  /**
@@ -21,7 +22,6 @@ function PostSwitchToDraftButton( {
21
22
  isScheduled,
22
23
  onClick,
23
24
  } ) {
24
- const isMobileViewport = useViewportMatch( 'small', '<' );
25
25
  const [ showConfirmDialog, setShowConfirmDialog ] = useState( false );
26
26
 
27
27
  if ( ! isPublished && ! isScheduled ) {
@@ -41,16 +41,17 @@ function PostSwitchToDraftButton( {
41
41
  };
42
42
 
43
43
  return (
44
- <>
44
+ <FlexItem isBlock>
45
45
  <Button
46
46
  className="editor-post-switch-to-draft"
47
47
  onClick={ () => {
48
48
  setShowConfirmDialog( true );
49
49
  } }
50
50
  disabled={ isSaving }
51
- variant="tertiary"
51
+ variant="secondary"
52
+ style={ { width: '100%', display: 'block' } }
52
53
  >
53
- { isMobileViewport ? __( 'Draft' ) : __( 'Switch to draft' ) }
54
+ { __( 'Switch to draft' ) }
54
55
  </Button>
55
56
  <ConfirmDialog
56
57
  isOpen={ showConfirmDialog }
@@ -59,7 +60,7 @@ function PostSwitchToDraftButton( {
59
60
  >
60
61
  { alertMessage }
61
62
  </ConfirmDialog>
62
- </>
63
+ </FlexItem>
63
64
  );
64
65
  }
65
66
 
@@ -3,10 +3,10 @@
3
3
  overflow: auto;
4
4
 
5
5
  // Extra left padding prevents checkbox focus borders from being cut off.
6
- margin-left: -$border-width * 4 - $border-width-focus;
7
- padding-left: $border-width * 4 + $border-width-focus;
8
- margin-top: -$border-width * 4 - $border-width-focus;
9
- padding-top: $border-width * 4 + $border-width-focus;
6
+ margin-left: -$border-width * 4 - $border-width-focus-fallback;
7
+ padding-left: $border-width * 4 + $border-width-focus-fallback;
8
+ margin-top: -$border-width * 4 - $border-width-focus-fallback;
9
+ padding-top: $border-width * 4 + $border-width-focus-fallback;
10
10
  }
11
11
 
12
12
  .editor-post-taxonomies__hierarchical-terms-choice {
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isEmpty } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -38,7 +33,11 @@ export function PostTemplate() {
38
33
 
39
34
  const { editPost } = useDispatch( editorStore );
40
35
 
41
- if ( ! isViewable || isEmpty( availableTemplates ) ) {
36
+ if (
37
+ ! isViewable ||
38
+ ! availableTemplates ||
39
+ ! Object.keys( availableTemplates ).length
40
+ ) {
42
41
  return null;
43
42
  }
44
43
 
@@ -31,6 +31,7 @@ class PostTitle extends Component {
31
31
  super( props );
32
32
 
33
33
  this.setRef = this.setRef.bind( this );
34
+ this.onPaste = this.onPaste.bind( this );
34
35
  }
35
36
  componentDidUpdate( prevProps ) {
36
37
  // Unselect if any other block is selected and blur the RichText.
@@ -60,16 +61,31 @@ class PostTitle extends Component {
60
61
  this.props.onSelect();
61
62
  }
62
63
 
63
- onPaste( { value, onChange, plainText } ) {
64
+ onPaste( { value, onChange, plainText, html } ) {
65
+ const { title, onInsertBlockAfter, onUpdate } = this.props;
66
+
64
67
  const content = pasteHandler( {
68
+ HTML: html,
65
69
  plainText,
66
- mode: 'INLINE',
67
- tagName: 'p',
68
70
  } );
69
71
 
70
- if ( typeof content === 'string' ) {
71
- const valueToInsert = create( { html: content } );
72
- onChange( insert( value, valueToInsert ) );
72
+ if ( content.length ) {
73
+ if ( typeof content === 'string' ) {
74
+ const valueToInsert = create( { html: content } );
75
+ onChange( insert( value, valueToInsert ) );
76
+ } else {
77
+ const [ firstBlock ] = content;
78
+ if (
79
+ ! title &&
80
+ ( firstBlock.name === 'core/heading' ||
81
+ firstBlock.name === 'core/paragraph' )
82
+ ) {
83
+ onUpdate( firstBlock.attributes.content );
84
+ onInsertBlockAfter( content.slice( 1 ) );
85
+ } else {
86
+ onInsertBlockAfter( content );
87
+ }
88
+ }
73
89
  }
74
90
  }
75
91
 
@@ -181,6 +197,7 @@ export default compose(
181
197
 
182
198
  return {
183
199
  postType: getEditedPostAttribute( 'type' ),
200
+ title: getEditedPostAttribute( 'title' ),
184
201
  isAnyBlockSelected: !! selectedId,
185
202
  isSelected: isPostTitleSelected(),
186
203
  isDimmed: selectionIsNested,
@@ -188,10 +205,10 @@ export default compose(
188
205
  };
189
206
  } ),
190
207
  withDispatch( ( dispatch ) => {
191
- const { undo, redo, togglePostTitleSelection } =
208
+ const { undo, redo, togglePostTitleSelection, editPost } =
192
209
  dispatch( editorStore );
193
210
 
194
- const { clearSelectedBlock, insertDefaultBlock } =
211
+ const { clearSelectedBlock, insertDefaultBlock, insertBlocks } =
195
212
  dispatch( blockEditorStore );
196
213
 
197
214
  return {
@@ -207,6 +224,12 @@ export default compose(
207
224
  onUnselect() {
208
225
  togglePostTitleSelection( false );
209
226
  },
227
+ onUpdate( title ) {
228
+ editPost( { title } );
229
+ },
230
+ onInsertBlockAfter( blocks ) {
231
+ insertBlocks( blocks, 0 );
232
+ },
210
233
  };
211
234
  } ),
212
235
  withInstanceId,
@@ -1,6 +1,4 @@
1
1
  .editor-post-trash.components-button {
2
- display: flex;
3
- justify-content: center;
4
- margin-top: $grid-unit-05;
5
2
  width: 100%;
3
+ display: block;
6
4
  }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { isEmpty } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -87,7 +82,7 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
87
82
  ] )
88
83
  );
89
84
 
90
- if ( ! isEmpty( nextMeta ) ) {
85
+ if ( Object.entries( nextMeta ).length ) {
91
86
  setMeta( nextMeta );
92
87
  }
93
88
 
@@ -115,7 +110,7 @@ function shimAttributeSource( settings ) {
115
110
  .filter( ( [ , { source } ] ) => source === 'meta' )
116
111
  .map( ( [ attributeKey, { meta } ] ) => [ attributeKey, meta ] )
117
112
  );
118
- if ( ! isEmpty( metaAttributes ) ) {
113
+ if ( Object.entries( metaAttributes ).length ) {
119
114
  settings.edit = createWithMetaAttributeSource( metaAttributes )(
120
115
  settings.edit
121
116
  );