@wordpress/editor 13.7.0 → 13.9.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 (41) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/entities-saved-states/index.js +12 -7
  3. package/build/components/entities-saved-states/index.js.map +1 -1
  4. package/build/components/post-excerpt/index.js +1 -1
  5. package/build/components/post-excerpt/index.js.map +1 -1
  6. package/build/components/post-taxonomies/hierarchical-term-selector.js +13 -7
  7. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  8. package/build/components/post-template/index.js +1 -7
  9. package/build/components/post-template/index.js.map +1 -1
  10. package/build/components/post-title/index.native.js +41 -11
  11. package/build/components/post-title/index.native.js.map +1 -1
  12. package/build/components/post-url/index.js +1 -1
  13. package/build/components/post-url/index.js.map +1 -1
  14. package/build/hooks/custom-sources-backwards-compatibility.js +21 -19
  15. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  16. package/build-module/components/entities-saved-states/index.js +12 -6
  17. package/build-module/components/entities-saved-states/index.js.map +1 -1
  18. package/build-module/components/post-excerpt/index.js +1 -1
  19. package/build-module/components/post-excerpt/index.js.map +1 -1
  20. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +15 -9
  21. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  22. package/build-module/components/post-template/index.js +1 -6
  23. package/build-module/components/post-template/index.js.map +1 -1
  24. package/build-module/components/post-title/index.native.js +41 -11
  25. package/build-module/components/post-title/index.native.js.map +1 -1
  26. package/build-module/components/post-url/index.js +1 -1
  27. package/build-module/components/post-url/index.js.map +1 -1
  28. package/build-module/hooks/custom-sources-backwards-compatibility.js +21 -18
  29. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  30. package/build-style/style-rtl.css +3 -19
  31. package/build-style/style.css +3 -19
  32. package/package.json +31 -32
  33. package/src/components/entities-saved-states/index.js +8 -6
  34. package/src/components/post-excerpt/index.js +1 -1
  35. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -0
  36. package/src/components/post-taxonomies/hierarchical-term-selector.js +26 -21
  37. package/src/components/post-taxonomies/style.scss +5 -20
  38. package/src/components/post-template/index.js +5 -6
  39. package/src/components/post-title/index.native.js +31 -8
  40. package/src/components/post-url/index.js +1 -1
  41. package/src/hooks/custom-sources-backwards-compatibility.js +13 -17
@@ -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,
@@ -61,7 +61,7 @@ export default function PostURL( { onClose } ) {
61
61
  { __( 'The last part of the URL.' ) }{ ' ' }
62
62
  <ExternalLink
63
63
  href={ __(
64
- 'https://wordpress.org/support/article/settings-sidebar/#permalink'
64
+ 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
65
65
  ) }
66
66
  >
67
67
  { __( 'Learn more.' ) }
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { mapValues, isEmpty } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -57,9 +52,13 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
57
52
  const mergedAttributes = useMemo(
58
53
  () => ( {
59
54
  ...attributes,
60
- ...mapValues(
61
- metaAttributes,
62
- ( metaKey ) => meta[ metaKey ]
55
+ ...Object.fromEntries(
56
+ Object.entries( metaAttributes ).map(
57
+ ( [ attributeKey, metaKey ] ) => [
58
+ attributeKey,
59
+ meta[ metaKey ],
60
+ ]
61
+ )
63
62
  ),
64
63
  } ),
65
64
  [ attributes, meta ]
@@ -83,7 +82,7 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
83
82
  ] )
84
83
  );
85
84
 
86
- if ( ! isEmpty( nextMeta ) ) {
85
+ if ( Object.entries( nextMeta ).length ) {
87
86
  setMeta( nextMeta );
88
87
  }
89
88
 
@@ -106,15 +105,12 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
106
105
  */
107
106
  function shimAttributeSource( settings ) {
108
107
  /** @type {WPMetaAttributeMapping} */
109
- const metaAttributes = mapValues(
110
- Object.fromEntries(
111
- Object.entries( settings.attributes ?? {} ).filter(
112
- ( [ , { source } ] ) => source === 'meta'
113
- )
114
- ),
115
- 'meta'
108
+ const metaAttributes = Object.fromEntries(
109
+ Object.entries( settings.attributes ?? {} )
110
+ .filter( ( [ , { source } ] ) => source === 'meta' )
111
+ .map( ( [ attributeKey, { meta } ] ) => [ attributeKey, meta ] )
116
112
  );
117
- if ( ! isEmpty( metaAttributes ) ) {
113
+ if ( Object.entries( metaAttributes ).length ) {
118
114
  settings.edit = createWithMetaAttributeSource( metaAttributes )(
119
115
  settings.edit
120
116
  );