@wordpress/editor 13.1.0 → 13.3.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 (138) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/error-boundary/index.js +24 -30
  4. package/build/components/error-boundary/index.js.map +1 -1
  5. package/build/components/media-categories/index.js +237 -0
  6. package/build/components/media-categories/index.js.map +1 -0
  7. package/build/components/page-attributes/parent.js +1 -1
  8. package/build/components/page-attributes/parent.js.map +1 -1
  9. package/build/components/post-author/select.js +1 -0
  10. package/build/components/post-author/select.js.map +1 -1
  11. package/build/components/post-format/index.js +1 -0
  12. package/build/components/post-format/index.js.map +1 -1
  13. package/build/components/post-publish-panel/postpublish.js +1 -0
  14. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  15. package/build/components/post-slug/index.js +1 -0
  16. package/build/components/post-slug/index.js.map +1 -1
  17. package/build/components/post-taxonomies/hierarchical-term-selector.js +7 -3
  18. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  19. package/build/components/post-template/index.js +8 -4
  20. package/build/components/post-template/index.js.map +1 -1
  21. package/build/components/post-url/index.js +1 -0
  22. package/build/components/post-url/index.js.map +1 -1
  23. package/build/components/provider/index.js +26 -8
  24. package/build/components/provider/index.js.map +1 -1
  25. package/build/components/provider/index.native.js +21 -14
  26. package/build/components/provider/index.native.js.map +1 -1
  27. package/build/components/provider/use-block-editor-settings.js +7 -4
  28. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  29. package/build/components/provider/use-block-editor-settings.native.js +1 -2
  30. package/build/components/provider/use-block-editor-settings.native.js.map +1 -1
  31. package/build/components/table-of-contents/index.js +3 -1
  32. package/build/components/table-of-contents/index.js.map +1 -1
  33. package/build/components/unsaved-changes-warning/index.js +1 -1
  34. package/build/components/unsaved-changes-warning/index.js.map +1 -1
  35. package/build/experiments.js +20 -0
  36. package/build/experiments.js.map +1 -0
  37. package/build/hooks/custom-sources-backwards-compatibility.js +16 -8
  38. package/build/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  39. package/build/hooks/default-autocompleters.js +2 -7
  40. package/build/hooks/default-autocompleters.js.map +1 -1
  41. package/build/index.js +14 -0
  42. package/build/index.js.map +1 -1
  43. package/build/index.native.js +14 -0
  44. package/build/index.native.js.map +1 -1
  45. package/build/lockUnlock.js +19 -0
  46. package/build/lockUnlock.js.map +1 -0
  47. package/build/store/defaults.js +1 -2
  48. package/build/store/defaults.js.map +1 -1
  49. package/build/store/selectors.js +1 -1
  50. package/build/store/selectors.js.map +1 -1
  51. package/build/utils/terms.js +9 -5
  52. package/build/utils/terms.js.map +1 -1
  53. package/build-module/components/error-boundary/index.js +24 -30
  54. package/build-module/components/error-boundary/index.js.map +1 -1
  55. package/build-module/components/media-categories/index.js +225 -0
  56. package/build-module/components/media-categories/index.js.map +1 -0
  57. package/build-module/components/page-attributes/parent.js +2 -2
  58. package/build-module/components/page-attributes/parent.js.map +1 -1
  59. package/build-module/components/post-author/select.js +1 -0
  60. package/build-module/components/post-author/select.js.map +1 -1
  61. package/build-module/components/post-format/index.js +1 -0
  62. package/build-module/components/post-format/index.js.map +1 -1
  63. package/build-module/components/post-publish-panel/postpublish.js +1 -0
  64. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  65. package/build-module/components/post-slug/index.js +1 -0
  66. package/build-module/components/post-slug/index.js.map +1 -1
  67. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +8 -5
  68. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  69. package/build-module/components/post-template/index.js +9 -5
  70. package/build-module/components/post-template/index.js.map +1 -1
  71. package/build-module/components/post-url/index.js +1 -0
  72. package/build-module/components/post-url/index.js.map +1 -1
  73. package/build-module/components/provider/index.js +21 -9
  74. package/build-module/components/provider/index.js.map +1 -1
  75. package/build-module/components/provider/index.native.js +20 -12
  76. package/build-module/components/provider/index.native.js.map +1 -1
  77. package/build-module/components/provider/use-block-editor-settings.js +5 -5
  78. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  79. package/build-module/components/provider/use-block-editor-settings.native.js +1 -2
  80. package/build-module/components/provider/use-block-editor-settings.native.js.map +1 -1
  81. package/build-module/components/table-of-contents/index.js +3 -1
  82. package/build-module/components/table-of-contents/index.js.map +1 -1
  83. package/build-module/components/unsaved-changes-warning/index.js +1 -1
  84. package/build-module/components/unsaved-changes-warning/index.js.map +1 -1
  85. package/build-module/experiments.js +10 -0
  86. package/build-module/experiments.js.map +1 -0
  87. package/build-module/hooks/custom-sources-backwards-compatibility.js +17 -9
  88. package/build-module/hooks/custom-sources-backwards-compatibility.js.map +1 -1
  89. package/build-module/hooks/default-autocompleters.js +2 -6
  90. package/build-module/hooks/default-autocompleters.js.map +1 -1
  91. package/build-module/index.js +1 -0
  92. package/build-module/index.js.map +1 -1
  93. package/build-module/index.native.js +1 -0
  94. package/build-module/index.native.js.map +1 -1
  95. package/build-module/lockUnlock.js +9 -0
  96. package/build-module/lockUnlock.js.map +1 -0
  97. package/build-module/store/defaults.js +1 -2
  98. package/build-module/store/defaults.js.map +1 -1
  99. package/build-module/store/selectors.js +1 -1
  100. package/build-module/store/selectors.js.map +1 -1
  101. package/build-module/utils/terms.js +9 -6
  102. package/build-module/utils/terms.js.map +1 -1
  103. package/build-style/style-rtl.css +0 -3
  104. package/build-style/style.css +0 -3
  105. package/package.json +30 -29
  106. package/src/components/autosave-monitor/test/index.js +8 -2
  107. package/src/components/editor-help/test/index.native.js +5 -5
  108. package/src/components/error-boundary/index.js +24 -37
  109. package/src/components/media-categories/index.js +247 -0
  110. package/src/components/page-attributes/parent.js +2 -2
  111. package/src/components/page-attributes/test/order.js +4 -14
  112. package/src/components/post-author/select.js +1 -0
  113. package/src/components/post-format/index.js +1 -0
  114. package/src/components/post-preview-button/test/index.js +5 -17
  115. package/src/components/post-publish-button/test/index.js +5 -17
  116. package/src/components/post-publish-panel/postpublish.js +1 -0
  117. package/src/components/post-publish-panel/style.scss +1 -5
  118. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -18
  119. package/src/components/post-saved-state/test/index.js +1 -5
  120. package/src/components/post-slug/index.js +1 -0
  121. package/src/components/post-taxonomies/hierarchical-term-selector.js +23 -17
  122. package/src/components/post-template/index.js +4 -4
  123. package/src/components/post-url/index.js +1 -0
  124. package/src/components/provider/index.js +120 -91
  125. package/src/components/provider/index.native.js +26 -17
  126. package/src/components/provider/use-block-editor-settings.js +60 -49
  127. package/src/components/provider/use-block-editor-settings.native.js +1 -2
  128. package/src/components/table-of-contents/index.js +3 -1
  129. package/src/components/unsaved-changes-warning/index.js +1 -1
  130. package/src/experiments.js +10 -0
  131. package/src/hooks/custom-sources-backwards-compatibility.js +16 -13
  132. package/src/hooks/default-autocompleters.js +1 -6
  133. package/src/index.js +1 -0
  134. package/src/index.native.js +1 -0
  135. package/src/lockUnlock.js +9 -0
  136. package/src/store/defaults.js +0 -1
  137. package/src/store/selectors.js +1 -1
  138. package/src/utils/terms.js +8 -5
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { pickBy, mapValues, isEmpty } from 'lodash';
4
+ import { mapValues, isEmpty } from 'lodash';
5
5
 
6
6
  /**
7
7
  * WordPress dependencies
@@ -70,18 +70,17 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
70
70
  attributes={ mergedAttributes }
71
71
  setAttributes={ ( nextAttributes ) => {
72
72
  const nextMeta = Object.fromEntries(
73
- Object.entries(
74
- // Filter to intersection of keys between the updated
75
- // attributes and those with an associated meta key.
76
- pickBy(
77
- nextAttributes,
78
- ( value, key ) => metaAttributes[ key ]
73
+ Object.entries( nextAttributes ?? {} )
74
+ .filter(
75
+ // Filter to intersection of keys between the updated
76
+ // attributes and those with an associated meta key.
77
+ ( [ key ] ) => key in metaAttributes
79
78
  )
80
- ).map( ( [ attributeKey, value ] ) => [
81
- // Rename the keys to the expected meta key name.
82
- metaAttributes[ attributeKey ],
83
- value,
84
- ] )
79
+ .map( ( [ attributeKey, value ] ) => [
80
+ // Rename the keys to the expected meta key name.
81
+ metaAttributes[ attributeKey ],
82
+ value,
83
+ ] )
85
84
  );
86
85
 
87
86
  if ( ! isEmpty( nextMeta ) ) {
@@ -108,7 +107,11 @@ const createWithMetaAttributeSource = ( metaAttributes ) =>
108
107
  function shimAttributeSource( settings ) {
109
108
  /** @type {WPMetaAttributeMapping} */
110
109
  const metaAttributes = mapValues(
111
- pickBy( settings.attributes, { source: 'meta' } ),
110
+ Object.fromEntries(
111
+ Object.entries( settings.attributes ?? {} ).filter(
112
+ ( [ , { source } ] ) => source === 'meta'
113
+ )
114
+ ),
112
115
  'meta'
113
116
  );
114
117
  if ( ! isEmpty( metaAttributes ) ) {
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { clone } from 'lodash';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
@@ -15,7 +10,7 @@ import { userAutocompleter } from '../components';
15
10
 
16
11
  function setDefaultCompleters( completers = [] ) {
17
12
  // Provide copies so filters may directly modify them.
18
- completers.push( clone( userAutocompleter ) );
13
+ completers.push( { ...userAutocompleter } );
19
14
 
20
15
  return completers;
21
16
  }
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ import './hooks';
6
6
  export { storeConfig, store } from './store';
7
7
  export * from './components';
8
8
  export * from './utils';
9
+ export * from './experiments';
9
10
 
10
11
  /*
11
12
  * Backward compatibility
@@ -13,3 +13,4 @@ import './hooks';
13
13
  export { store } from './store';
14
14
  export * from './components';
15
15
  export * from './utils';
16
+ export * from './experiments';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/experiments';
5
+ export const { lock, unlock } =
6
+ __dangerousOptInToUnstableAPIsOnlyForCoreModules(
7
+ 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
8
+ '@wordpress/editor'
9
+ );
@@ -27,5 +27,4 @@ export const EDITOR_SETTINGS_DEFAULTS = {
27
27
  richEditingEnabled: true,
28
28
  codeEditingEnabled: true,
29
29
  enableCustomFields: undefined,
30
- supportsLayout: true,
31
30
  };
@@ -785,7 +785,7 @@ export function isPreviewingPost( state ) {
785
785
  *
786
786
  * @param {Object} state Global application state.
787
787
  *
788
- * @return {string?} Preview Link.
788
+ * @return {string | undefined} Preview Link.
789
789
  */
790
790
  export function getEditedPostPreviewLink( state ) {
791
791
  if ( state.saving.pending || isSavingPost( state ) ) {
@@ -1,7 +1,12 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { groupBy, map, unescape as lodashUnescapeString } from 'lodash';
4
+ import { groupBy } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { decodeEntities } from '@wordpress/html-entities';
5
10
 
6
11
  /**
7
12
  * Returns terms in a tree form.
@@ -39,14 +44,12 @@ export function buildTermsTree( flatTerms ) {
39
44
  return fillWithChildren( termsByParent[ '0' ] || [] );
40
45
  }
41
46
 
42
- // Lodash unescape function handles ' but not ' which may be return in some API requests.
43
47
  export const unescapeString = ( arg ) => {
44
- return lodashUnescapeString( arg.replace( ''', "'" ) );
48
+ return decodeEntities( arg );
45
49
  };
46
50
 
47
51
  /**
48
52
  * Returns a term object with name unescaped.
49
- * The unescape of the name property is done using lodash unescape function.
50
53
  *
51
54
  * @param {Object} term The term object to unescape.
52
55
  *
@@ -68,5 +71,5 @@ export const unescapeTerm = ( term ) => {
68
71
  * @return {Object[]} Array of term objects unescaped.
69
72
  */
70
73
  export const unescapeTerms = ( terms ) => {
71
- return map( terms, unescapeTerm );
74
+ return ( terms ?? [] ).map( unescapeTerm );
72
75
  };